Advertisement
Guest User

TelnetPwner.py

a guest
Dec 18th, 2014
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.32 KB | None | 0 0
  1. ###### Created by _jun ######
  2.  
  3. # -*- coding : utf-8 -*-
  4.  
  5. #Imports
  6. import logging #Servant a desactiver le message d'erreur IPv6 de Scapy
  7. logging.getLogger("scapy.runtime").setLevel(logging.ERROR) #Pareil
  8. import time
  9. import os
  10. from scapy.all import * #Scapy import (To send packets)
  11. from pyfiglet import Figlet #Thank's to coyotus
  12. from subprocess import Popen, call, PIPE #Import which make me able to launch shell code
  13. #Fin des imports
  14.  
  15. #color
  16. global red
  17. red = '\033[31m'
  18. global green
  19. green  = '\033[32m'
  20. global reset
  21. reset = '\033[0m'
  22. global yellow
  23. yellow = '\033[33m'
  24. global cyan
  25. cyan = '\033[36m'
  26. global magenta
  27. magenta = '\033[35m'
  28. global cls
  29. cls = '\33c'
  30. #end color
  31.  
  32. #Fonctions
  33. def send(rhost):
  34.     """Sends a packet to test if telnet port is open"""
  35.  
  36.     print(yellow+"Pinging "+rhost+". . .")                                      #Pinging the rhost before sending a SYN packet.
  37.     try:                                                                        #
  38.         rep, non_rep = sr(IP(dst=rhost) / ICMP(), verbose=False, timeout=3)     #Trying to ping the remote host
  39.     except:                                                                     #
  40.         print(red+"Please enter a correct RHOST. The host is unreachable."+reset)           #RHOST down or not nicely typed.
  41.  
  42.     for elem in rep:
  43.         if elem[1].type == 0:                                                   #If rep have an element, so the host is up, and if the host is up, we can send a packet.
  44.             print(reset+elem[1].src+" is "+green+"up"+reset+".")
  45.             isUp = True
  46.    
  47.     if(isUp == True):
  48.         print(yellow+"Sending packet to "+rhost+". . . I can take a while. . . ")
  49.         packet = IP(dst=rhost)/TCP(sport=80, dport=23, flags='S')
  50.         rep, non_rep = sr(packet, verbose=0)
  51.  
  52.         for emis,recu in rep:
  53.             if recu[1].flags == 18:
  54.                 print(reset+rhost+" telnet's port is "+green+"open"+reset+".")
  55.                 choice = raw_input(green+"Would you like to connect to it ? [Y/n]\n> ")
  56.                 if(choice == "Y" or choice == "y"):
  57.                     print(red+"Connecting. . .")
  58.                     os.system('telnet '+rhost)
  59.                 else:
  60.                     print(cyan+"Goodbye, Sir !"+reset)
  61.                     time.sleep(2)
  62.                     print(cls)
  63.     else:
  64.         print(red+"The RHOST is down, or he's blocking ICMP requests. (Pings)\nYou can always try a manual telnet connexion and hope it'll work."+reset)
  65.  
  66. #Begin
  67. print(cls)
  68. msg = Figlet(font='slant')                  #WELCOME EVYBUDY
  69. print(msg.renderText('Telnet Pwner'))
  70.  
  71. rhost = raw_input("Please enter the IP address :\n> ")
  72. send(rhost) #Call the send() fonction with rhost argument
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement