diff --git a/Python/banner/README.md b/Python/banner/README.md new file mode 100644 index 00000000..419c91a0 --- /dev/null +++ b/Python/banner/README.md @@ -0,0 +1,22 @@ +# Banner grabber +- - - - - - +# Aim +A Banner is like a text message received from the host. It contains information about the services running on the host along with information about the ports.
+Here I've used some common ports like
+- 20/21: FTP +- 22: SSH(Secure Shell) +- 23: Telnet +- 25: SMTP +- 80: HTTP +- 156: SQL Server +- 443: HTTPS + +# Output +Banner info includes
+- Type of request +- Content-type +- Content-length +- Date +- Referrer-policy + +![alt-text](https://github.com/TaniaMalhotra/hacking-tools-scripts/blob/banner/Python/banner/Screenshot%20(591).png) diff --git a/Python/banner/Screenshot (591).png b/Python/banner/Screenshot (591).png new file mode 100644 index 00000000..611919df Binary files /dev/null and b/Python/banner/Screenshot (591).png differ diff --git a/Python/banner/banner.py b/Python/banner/banner.py new file mode 100644 index 00000000..982d24ac --- /dev/null +++ b/Python/banner/banner.py @@ -0,0 +1,31 @@ +import socket +from socket import AF_INET, SOCK_STREAM, SOCK_DGRAM +def scan_ports(name, port): + sock = socket.socket(AF_INET, SOCK_STREAM) + try: + #connect to the port + sock.connect((name,port)) + sock.send(b'200 OK\r\n') + # accepting banner as ascii string + banner = str(sock.recv(256), 'ascii') + # printing status portwise + print("[+] {port}/tcp is open".format_map(vars())) + # printing banner + print("- Banner") + print(banner) + except: + # if port is filtered or closed + print("{port} is filtered/closed/timedout".format_map(vars())) + +def main(): + target_host = input("Please enter the target host. For eg. www.example.com ") + # listing common ports for convenience + target_ports = [22, 25, 53, 80, 443] + socket.setdefaulttimeout(5) + # selecting one port a time + for port in target_ports: + scan_ports(target_host, port) + + +if __name__ == "__main__": + main()