-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscanv1.py
More file actions
95 lines (84 loc) · 2.62 KB
/
Copy pathscanv1.py
File metadata and controls
95 lines (84 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Eduardo'
#
# scanftp.py
#
# Copyright 2015 Eduardo Aranguiz <[email protected]>
import socket
import nmap
from ftplib import FTP
import sys
import os
import errno
if "linux" in sys.platform:
os.system("clear")
elif "win" in sys.platform:
os.system("cls")
else:
pass
s = socket.socket()
socket.setdefaulttimeout(2)
portList = []
class color:
BLUE = '\033[94m'
GREEN = '\033[92m'
RED = '\033[91m'
ENDC = '\033[0m'
print color.BLUE +("#####################################")+color.ENDC
print color.BLUE +("# SCAN V1.0 #")+color.ENDC
print color.BLUE +("#####################################")+color.ENDC
print
def scan(IP,PORT):
try:
socket.setdefaulttimeout(2)
s = socket.socket()
s.connect((IP,PORT))
if PORT >= 80:
s.send("HEAD / HTTP/1.0\r\n\r\n")
if PORT >= 80:
s.send('abcdefghijk\r\n')
ans = s.recv(1024)
return color.BLUE + ans + "[+] puerto abierto" + color.ENDC
except socket.error as error:
if error.errno == errno.ECONNRESET:
return color.BLUE + str(error) + " [+] puerto abierto" + color.ENDC
else:
return color.RED +"Error tipo " + str(error) + " [-] puerto cerrado" + color.ENDC
def ftpanon(IP):
ftp = FTP(IP)
return ftp.login() + ftp.retrlines('LIST')
IP=raw_input("ingresa ip a consultar: ")
try:
hostame = socket.gethostbyaddr(IP)
print("Hostname :" + str(hostame))
except:
pass
while True:
PUERTO = int(raw_input("ingresa puertos, si terminaste agrega un 0: "))
if PUERTO != 0:
portList.append(PUERTO)
else:
break
FTPanon = raw_input("quieres probar acceso anonimo al servidor ftp? (si) (no) :")
FTPanon = FTPanon.lower()
for port in portList:
nScan = nmap.PortScanner()
resultado = scan(IP,port)
estado = nScan.scan(IP, arguments='-n -sP -Pn -T4'+ str(port))
estado = nScan.scan(IP, arguments='-n -sP -Pn -T4'+ str(port))
print( "[+] revisando host "+ IP +":" + str(port)) + " en estado " + estado['scan'][IP]['status']['state'] + " " + estado['nmap']['scanstats']['timestr']
print "Banner: " + resultado
try:
if FTPanon == "si":
for port21 in portList:
try:
if port21 == 21:
print color.BLUE + ftpanon(IP) + color.ENDC
print color.BLUE +("acceso anonimo exitoso")+ color.ENDC
else:
pass
except Exception as fail:
print("Error " + str(fail))
except:
pass