本文整理汇总了Python中scapy.all.conf.verb方法的典型用法代码示例。如果您正苦于以下问题:Python conf.verb方法的具体用法?Python conf.verb怎么用?Python conf.verb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scapy.all.conf
的用法示例。
在下文中一共展示了conf.verb方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scan_ips
# 需要导入模块: from scapy.all import conf [as 别名]
# 或者: from scapy.all.conf import verb [as 别名]
def scan_ips(interface='wlan0', ips='192.168.1.0/24'):
"""a simple ARP scan with Scapy"""
try:
print('[*] Start to scan')
conf.verb = 0 # hide all verbose of scapy
ether = Ether(dst="ff:ff:ff:ff:ff:ff")
arp = ARP(pdst = ips)
answer, unanswered = srp(ether/arp, timeout = 2, iface = interface, inter = 0.1)
for sent, received in answer:
print(received.summary())
except KeyboardInterrupt:
print('[*] User requested Shutdown')
print('[*] Quitting...')
sys.exit(1)
示例2: SCAN_NETWORK
# 需要导入模块: from scapy.all import conf [as 别名]
# 或者: from scapy.all.conf import verb [as 别名]
def SCAN_NETWORK(MAC_ADDRESS, IP_RANGE, INTERFACE):
print("[+] Scanning network ... \n")
start_time = datetime.now()
conf.verb = 0
if MAC_ADDRESS == "None":
ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst = IP_RANGE), timeout = 2, iface=INTERFACE,inter=0.1)
else:
ans, unans = srp(Ether(src=MAC_ADDRESS, dst="ff:ff:ff:ff:ff:ff")/ARP(pdst = IP_RANGE), timeout = 2, iface=INTERFACE,inter=0.1)
for snd,rcv in ans:
try:
hostname = socket.gethostbyaddr(str(rcv[ARP].psrc))[0]
print(rcv.sprintf(r"%ARP.psrc% ["+color.CYAN+color.UNDERLINE+hostname+color.END+"] - %Ether.src%"))
except:
ERROR_print("Error occured while scanning!")
MAIN(IP_RANGE, SPOOF_MAC, INTERFACE)
stop_time = datetime.now()
total_time = stop_time - start_time
print("\n")
print("[*] Module Completed!")
print("[*] Scan Duration: %s \n" %(total_time))
示例3: run
# 需要导入模块: from scapy.all import conf [as 别名]
# 或者: from scapy.all.conf import verb [as 别名]
def run(self):
conf.verb = int(self.verbose)
self.strings = []
self.attack()
示例4: __init__
# 需要导入模块: from scapy.all import conf [as 别名]
# 或者: from scapy.all.conf import verb [as 别名]
def __init__(self, logger, config):
"""Initialises several things needed to define the daemons behaviour.
Args:
logger (logging.Logger): Used for logging messages.
interface (str): The network interface which should be used. (e.g. eth0)
pidfile (str): Path of the pidfile, used by the daemon.
stdout (str): Path of stdout, used by the daemon.
stderr (str): Path of stderr, used by the daemon.
dns_file (str): Path of file containing the nameservers.
Raises:
DaemonError: Signalises the failure of the daemon.
"""
# disable scapys verbosity global
conf.verb = 0
self.stdin_path = os.devnull
self.stdout_path = config['stdout']
self.stderr_path = config['stderr']
self.pidfile_path = config['pidfile']
self.pidfile_timeout = 5
# self.pidfile_timeout = 0
self.logger = logger
self.interface = None if config['interface'].lower() == 'all' else config['interface']
self.django_db = config['django-db']
# self.sniffthread = RegistrarSniffThread(self.interface, logger, self.django_db)
# self.sniffthread.daemon = True
self.sleeper = threading.Condition()
self.threads = {}
# Initialise threads
self.threads['sniffthread'] = RegistrarSniffThread(self.interface, logger, self.django_db)
self.threads['ssdpthread'] = SSDPDiscoveryThread(self.interface)
self.threads['nomodethread'] = StaticIPNoModeDiscoveryThread(self.interface, self.django_db, logger)
# declare all threads as deamons
for worker in self.threads:
self.threads[worker].daemon = True
示例5: run
# 需要导入模块: from scapy.all import conf [as 别名]
# 或者: from scapy.all.conf import verb [as 别名]
def run(self):
self.result = []
conf.verb = self.verbose
nm = port_scan(protocol='TCP', target=self.target, port=self.port)
for host in nm.all_hosts():
if nm[host]['tcp'][self.port]['state'] == "open":
print_success("Host: %s, port:%s is open" % (host, self.port))
self.get_target_info(host=host, port=self.port)
unique_device = [list(x) for x in set(tuple(x) for x in self.result)]
if len(self.result) > 0:
print_success("Find %s targets" % len(self.result))
print_table(TABLE_HEADER, *unique_device)
print('\r')
else:
print_error("Didn't find any target on network %s" % self.target)
示例6: settings_values
# 需要导入模块: from scapy.all import conf [as 别名]
# 或者: from scapy.all.conf import verb [as 别名]
def settings_values(self, iface, victim, gateway):
# Setting values
self.interface = iface
self.victimIP = victim
self.gatewayIP = gateway
# Disabling verbose mode
conf.verb = 0
示例7: run
# 需要导入模块: from scapy.all import conf [as 别名]
# 或者: from scapy.all.conf import verb [as 别名]
def run(self):
try:
ip = netifaces.ifaddresses(variables["interface"][0])[2][0]['addr']
except(ValueError, KeyError):
printError("Invalid interface!")
self.controller.kill = True
self.controller.error = "Invalid interface!"
return
ips = ip+"/24"
sconf.verb = 0
try:
ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst = ips), timeout = 2,iface=variables["interface"][0],inter=0.1)
except PermissionError:
self.controller.kill = True
self.controller.error = "Permission denied!"
return
for snd,rcv in ans:
ip = rcv.sprintf("%ARP.psrc%")
if ip not in self.targets:
self.targets.append(ip)
for target in self.targets:
if target not in self.attacking:
arpspoof = ArpSpoofer(variables["router"][0], target, self.controller)
arpspoof.start()
self.attacking.append(target)
time.sleep(30)
示例8: scan
# 需要导入模块: from scapy.all import conf [as 别名]
# 或者: from scapy.all.conf import verb [as 别名]
def scan():
try:
print(colors.purple+"Interfaces:"+colors.end)
for iface in netifaces.interfaces():
print(colors.yellow+iface+colors.end)
interface = input("\033[1;77m[>]\033[0m Interface: ").strip(" ")
try:
ip = netifaces.ifaddresses(interface)[2][0]['addr']
except(ValueError, KeyError):
printError("Invalid interface!")
return
ips = ip+"/24"
printInfo("Scanning...")
start_time = datetime.now()
conf.verb = 0
try:
ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst = ips), timeout = 2,iface=interface,inter=0.1)
except PermissionError:
printError('Permission denied!')
return
for snd,rcv in ans:
print(rcv.sprintf(colors.yellow+"r%Ether.src% - %ARP.psrc%"+colors.end))
stop_time = datetime.now()
total_time = stop_time - start_time
printSuccess("Scan completed!")
printSuccess("Scan duration: "+str(total_time))
except KeyboardInterrupt:
printWarning("Network scanner terminated.")
示例9: cmd_dhcp_discover
# 需要导入模块: from scapy.all import conf [as 别名]
# 或者: from scapy.all.conf import verb [as 别名]
def cmd_dhcp_discover(iface, timeout, verbose):
"""Send a DHCP request and show what devices has replied.
Note: Using '-v' you can see all the options (like DNS servers) included on the responses.
\b
# habu.dhcp_discover
Ether / IP / UDP 192.168.0.1:bootps > 192.168.0.5:bootpc / BOOTP / DHCP
"""
conf.verb = False
if iface:
iface = search_iface(iface)
if iface:
conf.iface = iface['name']
else:
logging.error('Interface {} not found. Use habu.interfaces to show valid network interfaces'.format(iface))
return False
conf.checkIPaddr = False
hw = get_if_raw_hwaddr(conf.iface)
ether = Ether(dst="ff:ff:ff:ff:ff:ff")
ip = IP(src="0.0.0.0",dst="255.255.255.255")
udp = UDP(sport=68,dport=67)
bootp = BOOTP(chaddr=hw)
dhcp = DHCP(options=[("message-type","discover"),"end"])
dhcp_discover = ether / ip / udp / bootp / dhcp
ans, unans = srp(dhcp_discover, multi=True, timeout=5) # Press CTRL-C after several seconds
for _, pkt in ans:
if verbose:
print(pkt.show())
else:
print(pkt.summary())
示例10: cmd_arp_sniff
# 需要导入模块: from scapy.all import conf [as 别名]
# 或者: from scapy.all.conf import verb [as 别名]
def cmd_arp_sniff(iface):
"""Listen for ARP packets and show information for each device.
Columns: Seconds from last packet | IP | MAC | Vendor
Example:
\b
1 192.168.0.1 a4:08:f5:19:17:a4 Sagemcom Broadband SAS
7 192.168.0.2 64:bc:0c:33:e5:57 LG Electronics (Mobile Communications)
2 192.168.0.5 00:c2:c6:30:2c:58 Intel Corporate
6 192.168.0.7 54:f2:01:db:35:58 Samsung Electronics Co.,Ltd
"""
conf.verb = False
if iface:
iface = search_iface(iface)
if iface:
conf.iface = iface['name']
else:
logging.error('Interface {} not found. Use habu.interfaces to show valid network interfaces'.format(iface))
return False
print("Waiting for ARP packets...", file=sys.stderr)
sniff(filter="arp", store=False, prn=procpkt)
示例11: cmd_arp_ping
# 需要导入模块: from scapy.all import conf [as 别名]
# 或者: from scapy.all.conf import verb [as 别名]
def cmd_arp_ping(ip, iface, verbose):
"""
Send ARP packets to check if a host it's alive in the local network.
Example:
\b
# habu.arp.ping 192.168.0.1
Ether / ARP is at a4:08:f5:19:17:a4 says 192.168.0.1 / Padding
"""
if verbose:
logging.basicConfig(level=logging.INFO, format='%(message)s')
conf.verb = False
if iface:
iface = search_iface(iface)
if iface:
conf.iface = iface['name']
else:
logging.error('Interface {} not found. Use habu.interfaces to show valid network interfaces'.format(iface))
return False
res, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=ip), timeout=2)
for _, pkt in res:
if verbose:
print(pkt.show())
else:
print(pkt.summary())
示例12: networkScanner
# 需要导入模块: from scapy.all import conf [as 别名]
# 或者: from scapy.all.conf import verb [as 别名]
def networkScanner():
conf.verb = 0
client_ip = netifaces.ifaddresses(conf.iface)[2][0]['addr']
client_netmask = netifaces.ifaddresses(conf.iface)[2][0]['netmask']
printInital("Network scan :", conf.iface, client_ip)
dos_method = options.dos_method if options.dos_method else "options"
if '-' in options.target_network or '/' in options.target_network: # Create new threads
global counter
global timeToExit
counter = 0
threadID = 0
for threadName in threadList:
thread = ThreadSIPNES(threadID, threadName, dos_method, options.dest_port, client_ip)
thread.start() # invoke the 'run()' function in the class
threads.append(thread)
threadID += 1
if "-" in options.target_network:
host_range = options.target_network.split("-")
host = ipaddress.IPv4Address(unicode(host_range[0]))
last = ipaddress.IPv4Address(unicode(host_range[1]))
if ipaddress.IPv4Address(host) > ipaddress.IPv4Address(last):
print ("\033[1;31;40m Error: Second value must bigger than First value.\033[0m")
exit(0)
# Fill the queue with hosts
for host in range(ipaddress.IPv4Address(host), ipaddress.IPv4Address(last) + 1): workQueue.put(ipaddress.IPv4Address(host)) # work to do!
# finish up the work
while not workQueue.empty(): pass # Wait for queue
timeToExit = 1 # Notify threads
for t in threads: t.join() # Wait for all threads to complete
elif "/" in options.target_network:
targetNetwork = ipaddress.IPv4Network(unicode(options.target_network), strict=False)
# Fill the queue with for runners
for host in targetNetwork.hosts(): workQueue.put(host) # work to do!
# finish up the work
while not workQueue.empty(): pass # Wait for queue to empty
timeToExit = 1 # Notify threads it's time to exit
for t in threads: t.join() # Wait for all threads to complete
else:
host = options.target_network
sip = sip_packet.sip_packet(dos_method, host, options.dest_port, client_ip, protocol="socket", wait=True)
result = sip.generate_packet()
if result["status"] and result["response"]['code'] == 200:
printResult(result,host)
counter += 1
print ("\033[31m[!] Network scan process finished and {0} live IP address(s) found.\033[0m".format(str(counter)))
# SIP-ENUM: SIP-based Enumerator
示例13: dosSmilator
# 需要导入模块: from scapy.all import conf [as 别名]
# 或者: from scapy.all.conf import verb [as 别名]
def dosSmilator():
conf.verb = 0
client_ip = netifaces.ifaddresses(conf.iface)[2][0]['addr']
client_netmask = netifaces.ifaddresses(conf.iface)[2][0]['netmask']
printInital("DoS attack simulation", conf.iface, client_ip)
dos_method = options.dos_method if options.dos_method else "invite"
utilities.promisc("on",conf.iface)
i = 0
while i < int(options.counter):
try:
toUser = random.choice([line.rstrip('\n') for line in open(options.to_user)])
fromUser = random.choice([line.rstrip('\n') for line in open(options.from_user)])
spUser = random.choice([line.rstrip('\n') for line in open(options.sp_user)])
userAgent = random.choice([line.rstrip('\n') for line in open(options.user_agent)])
pkt= IP(dst=options.target_network)
client = pkt.src
if options.random and not options.library:
client = utilities.randomIPAddress()
if options.manual and not options.library:
client = random.choice([line.rstrip('\n') for line in open(options.manual_ip_list)])
if options.subnet and not options.library:
client = utilities.randomIPAddressFromNetwork(client_ip, client_netmask, False)
send_protocol = "scapy"
if options.library:
send_protocol = "socket"
sip = sip_packet.sip_packet(str(dos_method), str(options.target_network), str(options.dest_port), str(client), str(fromUser), str(toUser), str(userAgent), str(spUser), send_protocol)
sip.generate_packet()
i += 1
utilities.printProgressBar(i,int(options.counter),"Progress: ")
except (KeyboardInterrupt):
utilities.promisc("off",conf.iface)
print ("Exiting traffic generation...")
raise SystemExit
print ("\033[31m[!] DoS simulation finished and {0} packet sent to {1}...\033[0m".format(str(i),str(options.target_network)))
utilities.promisc("off",conf.iface)
# Print functions:
示例14: cmd_icmp_ping
# 需要导入模块: from scapy.all import conf [as 别名]
# 或者: from scapy.all.conf import verb [as 别名]
def cmd_icmp_ping(ip, interface, count, timeout, wait, verbose):
"""The classic ping tool that send ICMP echo requests.
\b
# habu.icmp.ping 8.8.8.8
IP / ICMP 8.8.8.8 > 192.168.0.5 echo-reply 0 / Padding
IP / ICMP 8.8.8.8 > 192.168.0.5 echo-reply 0 / Padding
IP / ICMP 8.8.8.8 > 192.168.0.5 echo-reply 0 / Padding
IP / ICMP 8.8.8.8 > 192.168.0.5 echo-reply 0 / Padding
"""
if interface:
conf.iface = interface
conf.verb = False
conf.L3socket=L3RawSocket
layer3 = IP()
layer3.dst = ip
layer3.tos = 0
layer3.id = 1
layer3.flags = 0
layer3.frag = 0
layer3.ttl = 64
layer3.proto = 1 # icmp
layer4 = ICMP()
layer4.type = 8 # echo-request
layer4.code = 0
layer4.id = 0
layer4.seq = 0
pkt = layer3 / layer4
counter = 0
while True:
ans = sr1(pkt, timeout=timeout)
if ans:
if verbose:
ans.show()
else:
print(ans.summary())
del(ans)
else:
print('Timeout')
counter += 1
if count != 0 and counter == count:
break
sleep(wait)
return True
示例15: cmd_traceroute
# 需要导入模块: from scapy.all import conf [as 别名]
# 或者: from scapy.all.conf import verb [as 别名]
def cmd_traceroute(ip, port, iface):
"""TCP traceroute.
Identify the path to a destination getting the ttl-zero-during-transit messages.
Note: On the internet, you can have various valid paths to a device.
Example:
\b
# habu.traceroute 45.77.113.133
IP / ICMP 192.168.0.1 > 192.168.0.5 time-exceeded ttl-zero-during-transit / IPerror / TCPerror
IP / ICMP 10.242.4.197 > 192.168.0.5 time-exceeded ttl-zero-during-transit / IPerror / TCPerror / Padding
IP / ICMP 200.32.127.98 > 192.168.0.5 time-exceeded ttl-zero-during-transit / IPerror / TCPerror / Padding
.
IP / ICMP 4.16.180.190 > 192.168.0.5 time-exceeded ttl-zero-during-transit / IPerror / TCPerror
.
IP / TCP 45.77.113.133:http > 192.168.0.5:ftp_data SA / Padding
Note: It's better if you use a port that is open on the remote system.
"""
conf.verb = False
if iface:
iface = search_iface(iface)
if iface:
conf.iface = iface['name']
else:
logging.error('Interface {} not found. Use habu.interfaces to show valid network interfaces'.format(iface))
return False
pkts = IP(dst=ip, ttl=(1, 16)) / TCP(dport=port)
for pkt in pkts:
ans = sr1(pkt, timeout=1, iface=conf.iface)
if not ans:
print('.')
continue
print(ans.summary())
if TCP in ans and ans[TCP].flags == 18:
break
return True