DOE AGORA Qualquer valor

Advanced Linux Commands for the Modern Hacker

Advanced Linux Commands for the Modern Hacker

Shivam Kumar

3 min read

Photo by Kevin Ku on Unsplash

Linux, the backbone of most modern servers and a favorite amongst the hacker community, offers a robust collection of commands that grant unparalleled access to a computer’s inner workings. Whether you’re a penetration tester, ethical hacker, or just a Linux enthusiast, understanding advanced commands is essential to mastering Linux and its potential.

Disclaimer:The information provided here is meant for educational purposes only. Unauthorized hacking is illegal, and understanding these tools doesn’t grant license to misuse them.

1. Netcat (`nc`)

Overview: Netcat is a versatile networking utility. It can read from and write to TCP and UDP sockets, making it an essential tool for network debugging and exploration.

Use Cases: Creating chat systems, port scanning, banner grabbing, backdoors, file transfers.

Examples:

Simple Chat System:
1. Host: `nc -lvp 8080`
2. Client: `nc [host_ip] 8080`
File Transfer:
1. Receiver: `nc -lvp 8080 > received_file.txt`
2. Sender: `nc [receiver_ip] 8080 < send_file.txt`

— -

2. Tcpdump

Overview: Tcpdump captures packets that traverse a network interface. It’s invaluable for network troubleshooting and understanding traffic patterns.

Use Cases: Traffic analysis, malicious activity detection, debugging.

Examples:

Capture first 10 packets on eth0:
`tcpdump -i eth0 -c 10`

Capture HTTP requests:
`tcpdump -i eth0 ‘port 80’`

— -

3. Nmap

Overview: A powerful network scanning tool, Nmap can discover devices running on a network and find open ports along with various attributes of the network.

Use Cases: Network inventory, maintenance, vulnerability detection.

Examples:

OS Detection:
`nmap -O [target_ip]`

Aggressive Scan:
`nmap -A [target_ip]`

— -

4. Chroot

Overview: Chroot changes the apparent root directory for the current process and its children.

Use Cases: Creating an isolated environment for software compilation, testing, or service segregation.

Examples:

Isolate a Service:
1. `mkdir /srv/newroot`
2. `chroot /srv/newroot /usr/bin/someservice`

— -

5. Strace

Overview: Strace intercepts and logs system calls made and signals received by a process.

Use Cases: Debugging, performance profiling, error tracking.

Examples:

Track File Access:
`strace -e trace=file [command]`

— -

6. Lsof

Overview: Lsof lists open files, revealing the file descriptors used by a process.

Use Cases: Detecting rogue processes, security audits, system investigation.

Examples:

Find Processes Using a Directory:
`lsof +D /path/to/directory`

— -

7. Iptables

Overview:The user-space utility to configure the IP packet filter rules of the Linux kernel.

Use Cases:Building firewalls, IP masquerading, network translation.

Examples:

Allow Traffic on Port 80:
`iptables -A INPUT -p tcp — dport 80 -j ACCEPT`

— -

8. Grep

Overview: Grep searches input files for a pattern.

Use Cases: Data retrieval, log analysis, scripting.

Examples:

Find Errors in a Log File:
`grep “ERROR” /var/log/syslog`

— -

9. Sed & Awk

Overview: Sed and Awk are stream editors for filtering and transforming text.

Use Cases:Text processing, data extraction, report generation.

Examples:

Replace ‘old’ with ‘new’ in a File using Sed:
`sed ‘s/old/new/g’ filename`

Print the Second Column of a CSV using Awk:
`awk -F, ‘{print $2}’ filename.csv`

— -

10. Find

Overview: Find searches for files in a directory hierarchy.

Use Cases: System cleanup, data location, permission checks.

Examples:

Find Files Larger Than 100MB:
`find / -type f -size +100M`

— -

Extra : Cron

Overview: Cron is a time-based job scheduler.

Use Cases: Automating scripts, backups, notifications.

Examples:

Run a Script Every Day at 3 AM:
Add to crontab: `0 3 * * * /path/to/script.sh`

Conclusion:

These commands form the bedrock of Linux system management and networking. Mastery requires not just reading but hands-on practice. Use them wisely and always ensure you have permissions, especially when working on live environments or networks. The Linux command line is a world of endless possibilities, so never stop exploring!

Comentários

Ebook

Postagens mais visitadas