OpenWrt 的世界︰樹莓派 3B 【路由器】移星轉斗《四‧五》 Scapy 六

南宋之哲學家與教育家吕祖谦,字伯恭壽州人,因呂姓而郡望『東萊』,世稱『東萊先生』。著有《東萊博議》註解『左傳』,開宗第一篇即是《鄭伯克段於鄢》,其有言曰︰

釣者負魚,魚何負於釣?獵者負獸,獸何負於獵。莊公負叔段,叔段何負于莊公。

WiFi Pineapple

The WiFi Pineapple Mark V is the latest generation wireless network auditing tool from Hak5. With its custom, purpose built hardware and software, the WiFi Pineapple enable users to quickly and easily deploy advanced attacks using our intuitive web interface.

FruityWifi

Hi All,
FruityWifi is a wireless network auditing tool based in the wifi Pineapple. The application can be installed in any Debian based system adding the extra packages. Tested in Debian, Kali Linux, Kali Linux ARM (Raspberry Pi), Raspbian (Raspberry Pi).

fruitywifi.com

FruityWifi is an open source tool to audit wireless networks. It allows the user to deploy advanced attacks by directly using the web interface or by sending messages to it.

Initialy the application was created to be used with the Raspberry-Pi, but it can be installed on any Debian based system.

FruityWifi v2.0 has many upgrades. A new interface, new modules, Realtek chipsets support, Mobile Broadband (3G/4G) support, a new control panel, and more.

 

駭客大學的教具,且列為先修課了。

── 已發生的事,帶來省思;未發生的事,應當慎慮!! ──

─── 《音樂播放器原型機之《可能性》釣客與游魚??

 

當『工具』嫻熟了,因其『性能』高低,自有

Build your own tools

You can use Scapy to make your own automated tools. You can also extend Scapy without having to edit its source file.

If you have built some interesting tools, please contribute back to the github wiki !

Using Scapy in your tools

You can easily use Scapy in your own tools. Just import what you need and do it.

 

之時◎

宜乎『由淺入深』先『練習』的也◎

This first example takes an IP or a name as first parameter, send an ICMP echo request packet and display the completely dissected return packet:

#! /usr/bin/env python

import sys
from scapy.all import sr1,IP,ICMP

p=sr1(IP(dst=sys.argv[1])/ICMP())
if p:
    p.show()

※ 執行參考︰

root@kali:~/test# python ICMP-echo.py 5.168.168.20
Begin emission:
...............................Finished sending 1 packets.
........*
Received 40 packets, got 1 answers, remaining 0 packets
###[ IP ]### 
  version   = 4
  ihl       = 5
  tos       = 0x0
  len       = 28
  id        = 61102
  flags     = 
  frag      = 0
  ttl       = 64
  proto     = icmp
  chksum    = 0x30c5
  src       = 5.168.168.20
  dst       = 5.168.168.9
  \options   \
###[ ICMP ]### 
     type      = echo-reply
     code      = 0
     chksum    = 0xffff
     id        = 0x0
     seq       = 0x0
###[ Padding ]### 
        load      = '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

 

This is a more complex example which does an ARP ping and reports what it found with LaTeX formatting:

#! /usr/bin/env python
# arping2tex : arpings a network and outputs a LaTeX table as a result

import sys
if len(sys.argv) != 2:
    print "Usage: arping2tex <net>\n  eg: arping2tex 192.168.1.0/24"
    sys.exit(1)

from scapy.all import srp,Ether,ARP,conf
conf.verb=0
ans,unans=srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=sys.argv[1]),
              timeout=2)

print r"\begin{tabular}{|l|l|}"
print r"\hline"
print r"MAC & IP\\"
print r"\hline"
for snd,rcv in ans:
    print rcv.sprintf(r"%Ether.src% & %ARP.psrc%\\")
print r"\hline"
print r"\end{tabular}"

※ 執行參考︰

root@kali:~/test# python arping2tex.py 5.168.168.20
\begin{tabular}{|l|l|}
\hline
MAC & IP\\
\hline
b8:27:eb:d9:d7:2f & 5.168.168.20\\
\hline
\end{tabular}

 

Here is another tool that will constantly monitor all interfaces on a machine and print all ARP request it sees, even on 802.11 frames from a Wi-Fi card in monitor mode. Note the store=0 parameter to sniff() to avoid storing all packets in memory for nothing:

#! /usr/bin/env python
from scapy.all import *

def arp_monitor_callback(pkt):
    if ARP in pkt and pkt[ARP].op in (1,2): #who-has or is-at
        return pkt.sprintf("%ARP.hwsrc% %ARP.psrc%")

sniff(prn=arp_monitor_callback, filter="arp", store=0)

※ 執行參考︰

root@kali:~/test# python arpmonitor.py 
4c:e6:76:c4:ec:f8 5.168.168.1
b8:27:eb:c2:b0:6e 5.168.168.9
4c:72:b9:41:49:e1 5.168.168.2
b8:27:eb:c2:b0:6e 5.168.168.9
4c:72:b9:41:49:e1 5.168.168.2
b8:27:eb:c2:b0:6e 5.168.168.9
4c:72:b9:41:49:e1 5.168.168.2
b8:27:eb:c2:b0:6e 5.168.168.9
4c:72:b9:41:49:e1 5.168.168.2
b8:27:eb:c2:b0:6e 5.168.168.9
4c:72:b9:41:49:e1 5.168.168.2
b8:27:eb:c2:b0:6e 5.168.168.9
4c:72:b9:41:49:e1 5.168.168.2
b8:27:eb:c2:b0:6e 5.168.168.9
^Croot@kali:~/test#