-
Notifications
You must be signed in to change notification settings - Fork 0
/
cheatsheet.sh
executable file
·147 lines (97 loc) · 5.23 KB
/
cheatsheet.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
SJG_RED="\033[0;31m"
SJG_YELLOW='\033[1;33m'
SJG_NC='\033[0m'
CHEATSHEET=$1
function sj_gash_print_title() {
printf "$SJG_YELLOW $1\n"
}
function sj_gash_print_body() {
printf "$SJG_NC $1\n\n"
}
cheatsheets="arp, arpspoof, dd, diskutil, gpg, growpart, netstat, python, resize2fs, shutdown, tcpdump, xfs_growfs"
echo ""
if [ -z $CHEATSHEET ]; then
printf "$SJG_RED No program provided, available options are: $cheatsheets"
else
if [ $CHEATSHEET == "arp" ]; then
sj_gash_print_title "List all in ARP Cache - Linux"
sj_gash_print_body "arp"
sj_gash_print_title "List all in ARP Cache - Mac"
sj_gash_print_body "arp -a"
sj_gash_print_title "Create a static entry to prevent being arp spoofed"
sj_gash_print_body "arp -s <router-ip> <router-mac>"
elif [ $CHEATSHEET == "arpspoof" ]; then
sj_gash_print_title "Send a ARP request to entire network on the <nic> subnet and tell it to send requests which were meant for <router-ip> to the local IP instead"
sj_gash_print_body "arpspoof -i <nic - e.g. eth0> <router-ip - e.g. 192.168.0.1>"
sj_gash_print_title "Send a ARP request to <target-ip> on the <nic> subnet and tell it to send requests which were meant for <router-ip> to the local IP instead"
sj_gash_print_body "arpspoof -i <nic - e.g. eth0> -t <target-ip> <router-ip - e.g. 192.168.0.1>"
sj_gash_print_title "Poison both the target and host so traffic is captured in both directions"
sj_gash_print_body "arpspoof -i <nic - e.g. eth0> -t <target-ip> -r <poison> <fake-router-ip>"
elif [ $CHEATSHEET == "dd" ]; then
sj_gash_print_body "This should have been called cc (convert and copy), but, obviously that was taken."
sj_gash_print_title "Burn iso to device (rdisks speeds up process)"
sj_gash_print_body "sudo dd bs=1m if=file.iso of=/dev/rdisk{xxx}"
sj_gash_print_title "Format disk"
sj_gash_print_body "sudo dd bs=4096 if=/dev/zero of=/dev/sdcard/sd"
elif [ $CHEATSHEET == "diskutil" ]; then
sj_gash_print_title "Unmount an entire disk"
sj_gash_print_body "diskutil unmountDisk /dev/disk{xxx}"
sj_gash_print_title "Unmount a single volume"
sj_gash_print_body "diskutil unmount /dev/disk{xxx}"
sj_gash_print_title "Eject device"
sj_gash_print_body "diskutil eject /dev/disk{xxx}"
elif [ $CHEATSHEET == "gpg" ]; then
sj_gash_print_title Retrieve my key
sj_gash_print_body "gpg --receive-keys simon@jakowicz.com"
sj_gash_print_title "Encrypt using my public key"
sj_gash_print_body "gpg -e -r simon@jakowicz.com -o <output-file>"
sj_gash_print_title "Export my public key"
sj_gash_print_body "gpg --export simon@jakowicz.com > <public-key-file>"
sj_gash_print_title "Import my public key"
sj_gash_print_body "gpg --import <public-key-file>"
sj_gash_print_title "Decrypt symmetric or asymmetric"
sj_gash_print_body "gpg -d <gpg-file>"
sj_gash_print_title "Symmetric Encryption"
sj_gash_print_body "gpg --symmetric <file-to-encrypt>"
elif [ $CHEATSHEET == "growpart" ]; then
sj_gash_print_title "Resize the /dev/disk0 partition to the size of it’s volume"
sj_gash_print_body "growpart /dev/disk{xxx}"
elif [ $CHEATSHEET == "netstat" ]; then
sj_gash_print_title "Run as sudo for more information"
sj_gash_print_body "sudo netstat -tupln # (tcp, upd, pid, listen, numeric)"
elif [ $CHEATSHEET == "python" ]; then
sj_gash_print_title "Start HTTP server Python 2"
sj_gash_print_body "python -m SimpleHTTPServer 8000"
sj_gash_print_title "Start HTTP server Python 3"
sj_gash_print_body "python -m http.server 3000"
elif [ $CHEATSHEET == "resize2fs" ]; then
sj_gash_print_title "Extend a 'ext2, ext3, ext4' filesystem after resizing the partition"
sj_gash_print_body "sudo resize2fs /dev/disk[0-9]"
elif [ $CHEATSHEET == "shutdown" ]; then
sj_gash_print_title "Restart"
sj_gash_print_body "shutdown -r"
sj_gash_print_body "init 6"
sj_gash_print_title "Shutdown now"
sj_gash_print_body "poweroff"
sj_gash_print_body "init 0"
sj_gash_print_title "shutdown in 30 mins"
sj_gash_print_body "shutdown +30"
elif [ $CHEATSHEET == "tcpdump" ]; then
sj_gash_print_title "Dump all traffic, don’t addresses to names"
sj_gash_print_body "tcpdump -n"
sj_gash_print_title "Dump traffic on a specific interface"
sj_gash_print_body "tcpdump -i <interface - e.g. eth0>"
sj_gash_print_title "Dump traffic to a specific host"
sj_gash_print_body "tcpdump host www.google.com"
sj_gash_print_title "Capture the traffic from a specific interface, source, destination and destination port"
sj_gash_print_body "tcpdump -i eth0 src <source-ip e.g. 192.168.0.100> and dst <dst-ip 12.34.56.78> and dst port <dest-port e.g. 80>"
sj_gash_print_title "-nn Do not resolve hostnames or ports. -s0 will set the packet length to unlimited for maximum output"
sj_gash_print_body "tcpdump -i eth0 -nn -s0 -v port 80"
elif [ $CHEATSHEET == "xfs_growfs" ]; then
sj_gash_print_title "Extend a bfs filesystem after resizing the partition"
sj_gash_print_body "sudo xfs_growfs -d /dev/disk[0-9]"
else
printf "$SJG_RED Could not find cheatsheet for: $CHEATSHEET"
fi
fi