-
Notifications
You must be signed in to change notification settings - Fork 7
/
hacksheet.tex
656 lines (534 loc) · 19.8 KB
/
hacksheet.tex
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
% This work is licensed under the following license:
%
% Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported
%
% Please see the file COPYING for more information.
\documentclass[10pt,landscape]{article}
\usepackage{alltt}
\usepackage{cprotect}
\usepackage{enumitem}
\usepackage[T1]{fontenc}
\usepackage[landscape,margin=13mm,footskip=1pt,includefoot]{geometry}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage{multicol}
\usepackage{setspace}
%\usepackage{titlesec}
\usepackage{upquote}
\usepackage{xspace}
\usepackage{wasysym}
\graphicspath{{figs/}}
\pagestyle{empty}
\parindent=0pt
\hypersetup{
colorlinks=true, % false: boxed links; true: colored links
linkcolor=red, % color of internal links
citecolor=cyan, % color of links to bibliography
filecolor=magenta, % color of file links
urlcolor=blue % color of external links
}
\setitemize{itemsep=1pt,topsep=0pt,parsep=1pt,leftmargin=10pt}
%\titleformat{\subsection}{\sc}{}{}{}
%\titlespacing{\subsection}{0pt}{*0}{*1}
\newcommand{\todo}[1]{\textit{\textcolor{red}{TODO: #1}}}
\newcommand{\minisec}[1]{\textsc{#1}\\}
\newcommand{\first}{\emph{(i)}~}
\newcommand{\second}{\emph{(ii)}~}
\newcommand{\third}{\emph{(iii)}~}
\newcommand{\fourth}{\emph{(iv)}~}
\newcommand{\fifth}{\emph{(v)}~}
\newcommand{\os}[1]{\texttt{\footnotesize{#1}}}
\newcommand{\unix}{\os{U}}
\newcommand{\freebsd}{\os{F}}
\newcommand{\bsd}{\os{B}}
\newcommand{\linux}{\os{L}}
\newcommand{\solaris}{\os{S}}
\newcommand{\macos}{\os{M}}
\newcommand{\windows}{\os{W}}
\newcommand{\xp}{\os{xp}}
\newcommand{\kk}{\os{2k}}
\newcommand{\kkt}{\os{2k3}}
\newcommand{\kke}{\os{2k8}}
\newcommand{\seven}{\os{7}}
\newenvironment{action}[1]
{\paragraph{$\star$~#1}\begin{itemize}[leftmargin=1cm]}
{\end{itemize}}
\newcommand{\cmd}[2]{\item[#1] {\small\tt\# #2}}
\newcommand{\comment}[1]{\textrm{\small(#1)}}
\newcommand{\bulletpoint}[1]{\item {\small #1}}
\newcommand{\app}[1]{\footnotesize\sc{#1}}
\newcommand{\tool}[2]{\item[#1] {\footnotesize\sc{#2}}\xspace}
\newcommand{\button}[1]{\footnotesize\sf#1}
\newcommand{\click}{$\rightarrow$\xspace}
\newcommand{\checkbox}{\CheckedBox}
\newcommand{\home}{\raise.17ex\hbox{$\scriptstyle\sim$}}
\begin{document}
\begin{multicols*}{3}
{\Huge\scshape
HackSheet\hspace{-2pt}\raisebox{15pt}{\tiny{master}}\hspace{-4pt}
}
%\hfill\includegraphics[width=.4\linewidth]{bro-logo-small}
%\vspace{-38pt}
{\scriptsize
\setstretch{1.5}
\begin{tabular}{l l}
%Version: & \today\\
Author: & \href{https://github.com/berke1337}{BERKE1337}\\
Web: & \url{https://github.com/berke1337/hacksheet}\\
License: & \href{http://creativecommons.org/licenses/by-nc-sa/3.0/}
{Attribution-NonCommercial-ShareAlike 3.0 Unported}
\end{tabular}
}
%\hfill
%\href{http://creativecommons.org/licenses/by-nc-sa/3.0/}
%{\includegraphics[width=.2\linewidth]{by-nc-sa}}
%\vspace{-10pt}
\vspace{-10pt}
\section*{Terminology}
Each command contains a list of flags that indicate the OS requirement: Linux
(\linux), BSD (\bsd), FreeBSD (\freebsd), Mac OS (\macos), Solaris (\solaris),
UNIX (\unix), and Windows (\windows).
\section*{Reconnaissance}
\subsection*{Scanning}
\begin{action}{Ping sweep of subnet and host range}
\cmd{\unix}{nmap -sP 10.0.0.0/24 192.168.0.128-254}
\end{action}
\begin{action}{List all computers in network}
\cmd{\windows}{net view}
\end{action}
\begin{action}{Scan specific TCP and UDP ports}
\cmd{\unix}{nmap -pT:21-25,80,U:5000-6000 target}
\end{action}
\begin{action}{TCP SYN scan without connecting}
\cmd{\unix}{nmap -P0 -sS target}
\end{action}
\begin{action}{Detect OS}
\cmd{\unix}{nmap -O target}
\cmd{\unix}{p0f -s trace.pcap}
\end{action}
\begin{action}{Grab application banners}
\cmd{\unix}{nmap -sV target}
\cmd{\unix}{echo QUIT | nc target 1-1024}
\end{action}
\subsection*{Wireless}
\section*{Vulnerability Scanning}
\subsection*{Web}
\begin{action}{Look for web server vulnerabilities}
\cmd{\unix}{nikto -host 10.0.0.1}
\end{action}
\section*{Hardening}
\subsection*{Physical}
\begin{action}{Check devices}
\bulletpoint{Hardware keylogger (e.g., USB dongles)}
\bulletpoint{Rogue WiFi cards}
\end{action}
\subsection*{OS \& Software}
\begin{action}{Check for suspicious package repositories}
\cmd{\linux}{vi /etc/apt/sources.list} \comment{Ubuntu}
\cmd{\linux}{vi /etc/yum.repos.d/*} \comment{RHEL/Fedora}
\end{action}
\begin{action}{Run package updates}
\cmd{\linux}{yum upgrade \emph{package}}
\cmd{\linux}{apt-get upgrade \emph{package}}
\end{action}
\begin{action}{Update Kernel}
\cmd{\linux}{yum update kernel} \comment{RHEL/Fedora}
\cmd{\linux}{apt-cache search linux-image; apt-get install
linux-image-\emph{x.x.x-xx}} \comment{Debian}
\end{action}
\begin{action}{Harden SSHD}
\tool{\unix}{fail2ban}
\cmd{\unix}{vi /etc/ssh/sshd\_config\\
Protocol 2\\
AllowUsers root admin webmaster\\
AllowGroup sshusers\\
PasswordAuthentication no\\
HostbasedAuthentication no\\
RSAAuthentication yes\\
PubkeyAuthentication yes\\
PermitEmptyPasswords no\\
PermitRootLogin no\\
ServerKeyBits 2048\\
IgnoreRhosts yes\\
RhostsAuthentication no\\
RhostsRSAAuthentication no}
\end{action}
\begin{action}{Enable ASLR}
\tool{\windows}{ProcessExplorer \click Select Columns \click Enable ASLR}
\tool{\windows}{EMET}
\cmd{\windows}{reg add
hklm{\textbackslash}%
system{\textbackslash}%
currentcontrolset{\textbackslash}%
control{\textbackslash}
session manager{\textbackslash}%
memory management\\
/v moveimages /t REG\_DWORD /d 1 /f}
\cmd{\linux}{echo 2 > /proc/sys/kernel/randomize\_va\_space\\
/etc/sysctl.conf:\\kernel.randomize\_va\_space = 2}
\cmd{\solaris}{sxadm enable -c model=tagged-files aslr}
\cmd{\solaris}{sxadm enable -c model=all aslr}
\end{action}
\begin{action}{Enable DEP}
\tool{\windows}{ProcessExplorer \click Select Columns \click DEP Status}
\tool{\windows}{EMET}
\cmd{\windows}{\comment{Vista}\\
bcdedit /set nx AlwaysOn\\
bcdedit /set nx OptOut}
\cmd{\linux}{echo 1 > /proc/sys/kernel/exec-shield\\
/etc/sysctl.conf: kernel.exec-shield = 1}
\cmd{\macos}{echo 1 > /proc/sys/kernel/nx\\
/etc/sysctl.conf: kernel.nx = 1}
\cmd{\solaris}{set noexec\_user\_stack=1 {>}> /etc/system}
\end{action}
\subsection*{User Management}
\begin{action}{Inspect logged in and past users}
\cmd{\unix}{w}
\cmd{\unix}{last | head}
\cmd{\unix}{ps -ef | awk '\$6 != "?"'} (interactive procs)
\tool{\windows}{PsLoggedOn}
\tool{\windows}{Task Manager \click Users Tab}
\cmd{\windows}{wmic computersystem get username}
\cmd{\windows}{wmic /node:\emph{remotecomputer} computersystem \\ get username}
\end{action}
\begin{action}{Show account security settings}
\cmd{\unix}{passwd -S \emph{user}}
\cmd{\linux}{chage -l \emph{user}}
\cmd{\windows}{net accounts}
\cmd{\windows}{net accounts /domain}
\end{action}
\begin{action}{View Users}
\cmd{\windows}{wmic useraccount list brief}
\end{action}
\begin{action}{Look for users with root privileges}
\cmd{\unix}{awk -F: '\$3 == 0 \{print \$1\}' /etc/passwd}
\cmd{\windows}{net localgroup administratos}
\end{action}
\begin{action}{Look for users with empty passwords}
\cmd{\unix}{awk -F: '\$2 == "" \{print \$1\}' /etc/shadow}
\end{action}
\begin{action}{Make passwords expire}
\cmd{\windows}{wmic path Win32\_UserAccount Set PasswordExpires=True}
\cmd{\windows}{wmic path Win32\_UserAccount where name="\emph{username}" Set PasswordExpires=True}
\cmd{\windows}{wmic path /Node:\emph{remotecomputer} Win32\_UserAccount where name="\emph{username}" Set PasswordExpires=True}
\cmd{\linux}{chage -d 0 \emph{username}}
\end{action}
\begin{action}{Set maximum number of login failures}
\cmd{\linux}{faillog -M \emph{maxNumber} -u \emph{username}}
\cmd{\linux}{faillog -r -u \emph{username}}
\cmd{\windows}{net accounts /lockoutthreshold:\emph{maxNumber}}
\cmd{\windows}{net accounts /lockoutduration:\emph{numberOfMinutes}}
\end{action}
\begin{action}{Verify group memberships}
\cmd{\unix}{vi /etc/group} \comment{admin, sudo, wheel}
\end{action}
\begin{action}{Check \texttt{sudo} users}
\cmd{\unix}{visudo}
\end{action}
\begin{action}{Check crontab users}
\cmd{\unix}{for u in \$(cut -f1 -d: /etc/passwd); do crontab -u \$u -l; done}
\end{action}
\begin{action}{Check remote authentication}
\cmd{\unix}{vi \home/.rhosts}
\cmd{\unix}{vi \home/.ssh/*}
\end{action}
\begin{action}{Change passwords}
\cmd{\unix}{pwgen -sy} \comment{generate strong passwords}
\cmd{\unix}{passwd \emph{user}}
\cmd{\windows}{net user \emph{user} *}
\end{action}
\subsection*{File System}
\begin{action}{Secure mount points}
\cmd{\unix}{mount -o nodev,noexec,nosuid /dev.. /tmp}
\end{action}
\begin{action}{List file attributes}
\cmd{\linux}{lsattr /var/log/foo}
\cmd{\bsd}{ls -ol /var/log/foo}
\cmd{\windows}{cacls.exe file.txt}
\end{action}
\begin{action}{File creation date}
\cmd{\windows}{dir /tc /od}
\cmd{\unix}{ls -li /etc | sort -n}
\end{action}
\begin{action}{System file checker }
\cmd{\windows}{sfc /scannow}
\end{action}
\begin{action}{File signature serification}
\cmd{\windows}{sigverif}
\tool{\windows}{sigcheck}
\cmd{\windows}{sigcheck -e -u -s c:{\textbackslash} }
\end{action}
\begin{action}{Make files append-only}
\cmd{\linux}{chattr +a /var/log/foo}
\end{action}
\subsection*{Network}
\begin{action}{Show firewall rules}
\cmd{\linux}{for t in nat mangle filter raw; do iptables -t \$t -nL; done}
\cmd{\windows}{netsh firewall show portopening}
\cmd{\windows}{netsh firewall show allowedprogram}
\cmd{\windows}{netsh firewall show config}
\cmd{\windows}{netsh firewall show state}
\end{action}
\begin{action}{Enable Windows firewall in block mode}
\cmd{\windows}{netsh firewall set opmode mode = enable} \emph{(Server 2003 and earlier)}
\cmd{\windows}{netsh advfirewall set allprofiles state on} \emph{(Vista and later)}
\cmd{\windows}{netsh advfirewall set allprofiles firewallpolicy "blockinboundalways,allowoutbound"} \emph{(Vista and later)}
\end{action}
\begin{action}{Add Windows port opening for specific host}
\cmd{\windows}{netsh firewall add portopening protocol = TCP port = 3389 name = RDP mode = ENABLE scope = CUSTOM addresses = 192.168.99.1} \emph{(Server 2003 and earlier)}
\end{action}
\begin{action}{Remove Windows port opening}
\cmd{\windows}{netsh firewall delete portopening protocol = TCP port = 3389 name = RDP} \emph{(Server 2003 and earlier)}
\end{action}
\begin{action}{Close ports (outbound)}
\cmd{\windows}{netsh advfirewall firewall add rule name="BlockAIM" \\
protocol=TCP\\
dir=out remoteport=4099 action=block}\emph{(Vista and later)}
\end{action}
\begin{action}{Open ports (inbound)}
\cmd{\windows}{netsh advfirewall firewall add rule name="Allow HTTP" \\
protocol=TCP\\
dir=in localport=80 action=allow}\emph{(Vista and later)}
\end{action}
\begin{action} {Shut down SMB vulnerable services}
\tool{\windows}{Seconfig XP}
\checkbox{Disable NetBIOS over TCP/IP (all interfaces)}
\checkbox{Disable SMB over TCP/IP}
\checkbox{Disable RPC over TCP/IP}
\click \button{Apply}
\click \button{ Yes}
\end{action}
\begin{action}{Check DNS resolver}
\cmd{\unix}{vi /etc/resolv.conf}
\end{action}
\begin{action}{Disable IPv6}
\cmd{\linux}{ipv6.disable=1} \comment{add to kernel line}
\cmd{\linux}{vi /etc/sysctl.conf\\
net.ipv6.conf.all.disable\_ipv6 = 1\\
net.ipv6.conf.<interface0>.disable\_ipv6 = 1\\
net.ipv6.conf.<interfaceN>.disable\_ipv6 = 1\\
vi /etc/hosts \comment{comment IPv6 hosts}}
\cmd{\linux}{vi /etc/sysconfig/network\\
NETWORKING\_IPV6=no\\
IPV6INIT=no\\
service network restart}
\cmd{\linux}{vi /etc/modprobe.conf\\
install ipv6 /bin/true \comment{append to file}}
\cmd{\linux}{vi /etc/modprobe.conf \comment{RHEL/CentOS}\\
alias net-pf-10 off}
\cmd{\linux}{vi /etc/modprobe.conf \comment{Debian/Ubuntu}\\
alias net-pf-10 off \\
alias ipv6 off}
\cmd{\windows}{reg add
hklm{\textbackslash}system{\textbackslash}currentcontrolset{\textbackslash}services{\textbackslash}
tcpip6{\textbackslash}parameters /v DisabledComponents /t REG\_DWORD /d 255}
\end{action}
\begin{action}{Check network configuration}
\cmd{\linux}{vi /etc/network/interfaces} \comment{Ubuntu}
\cmd{\linux}{vi /etc/sysconfig/network-scripts/ifcfg-eth*} \comment{RHEL}
\end{action}
\vfill
\section*{Forensics}
\subsection*{Processes}
\begin{action}{Inspect startup items}
\cmd{\linux}{initctl show-config}
(\href{http://upstart.ubuntu.com/cookbook/upstart_cookbook.pdf}{upstart},
Ubuntu)
\cmd{\freebsd}{less /etc/rc.local} (deprecated)
\cmd{\freebsd}{grep local\_start /etc/defaults/rc.conf}
\tool{\windows}{Autoruns}
\click\button{Options}
\click\button{Filter Options}
\checkbox{Verify code signatures}
\checkbox{Hide Microsoft entries}
\end{action}
\begin{action}{Find SETUID and SETGID files and types}
\cmd{\unix}{find / \textbackslash( -perm -4000 -o -perm -2000 \textbackslash)
-exec file \textbackslash\{\textbackslash\} \textbackslash;}
\cmd{\unix}{crontab -e\\
0 4 * * * find / \textbackslash( -perm -4000 -o -perm -2000 \textbackslash)
-type f > /var/log/sidlog.new \&\&
diff /var/log/sidlog.new /var/log/sidlog \&\&
mv /var/log/sidlog.new /var/log/sidlog}
\end{action}
\begin{action}{Find world/group writeable directories}
\cmd{\unix}{find / \textbackslash( -perm -g+w -o -perm -o+w \textbackslash)
-type d -exec ls -ald \textbackslash\{\textbackslash\} \textbackslash;}
\end{action}
\begin{action}{Find all unsigned processes}
\tool{\windows}{ProcessExplorer}
\button{Options} \click \button{Verify Image Signatures}
\end{action}
\begin{action} {View Process File Location}
\tool{\windows}{ProcessExplorer}
\button{View} \click \button{Select Columns...} \click \button{Image Path}
\end{action}
\begin{action}{Currently Running Tasks/Processes}
\cmd{\windows}{tasklist -svc}
\cmd{\linux\unix}{ps aux | less}
\cmd{\linux\unix}{top}
\cmd{\linux\unix}{ps -u \emph{user}}
\end{action}
\begin{action}{Kill Tasks/Processes}
\cmd{\windows}{taskkill -pid \emph{pid}}
\cmd{\linux\unix}{kill \emph{pid}}
\end{action}
\subsection*{Network}
\begin{action}{Display listening TCP/UDP ports}
\cmd{\linux\unix}{netstat -plunt}
\cmd{\windows}{netstat -abon | select-string -Context 1, 0 LISTENING} \emph{(PowerShell Only)}
\cmd{\windows}{netstat -aon | findstr LISTENING} \emph{(cmd.exe)}
\tool{\windows}{tcpview}
\cmd{\bsd}{netstat -p tcp -an | egrep 'Proto|LISTEN|udp'}
\cmd{\unix}{lsof -nPi | awk '/LISTEN/'}
\cmd{\freebsd}{sockstat -4 -l}
\end{action}
\begin{action}{Check active connections to find backdoors}
\cmd{\linux}{netstat -punt}
\cmd{\unix}{lsof -nPi | awk '/ESTABLISHED/'}
\end{action}
\subsection*{Cleanup}
\begin{action}{Kill all processes accessing a mount point}
\cmd{\unix}{fuser -k -c /mnt/secret}
\end{action}
\section*{Miscellaneous}
\subsection*{Date and Time}
\begin{action}{Set date and time}
\cmd{\unix}{date MMddhhmm[[cc]yy]}
\cmd{\windows}{date}
\cmd{\windows}{time}
\end{action}
\subsection*{Network}
\newcommand{\cisco}{\app{cisco}}
\begin{action}{Show the active config of a Cisco device}
\cmd{\cisco}{show running-config}
\end{action}
\begin{action}{Forward a TCP/UDP port}
\cmd{\unix}{mkfifo f ;\\
nc -l 80 < f | nc 127.0.0.1 6666 > f \&}
\cmd{\linux}{iptables -t nat -A OUTPUT|POSTROUTING \textbackslash\\
-p tcp -s x.x.x.x -{}-sport 80 -j SNAT \textbackslash\\
-{}-to-destination 6666}
\cmd{\linux}{iptables -t nat -A INPUT|PREROUTING \textbackslash\\
-p tcp -d x.x.x.x -{}-dport 80 -j DNAT \textbackslash\\
-{}-to-destination :6666}
% Can we do this with -j REDIRECT as well?
%iptables -A PREROUTING -i eth1 -p tcp -m tcp -{}-dport 80 -j REDIRECT -{}-to-port 8080
\end{action}
\subsection*{Databases}
\newcommand{\mysql}{\app{mysql}}
\newcommand{\postgres}{\app{psql}}
\newcommand{\mssql}{\app{mssql}}
\begin{action}{Export/Restore}
\cmd{\unix}{mysqldump -u \emph{username} -p \emph{database\_name} > dump.sql}
\cmd{\unix}{mysql -u \emph{username} -p \emph{database\_name} < dump.sql}
\cmd{\unix}{pg\_dump \emph{database\_name} > dump.sql}
\cmd{\unix}{psql -d \emph{database\_name} -f dump.sql}
\end{action}
\begin{action}{Change user password}
\cmd{\mysql}{SET PASSWORD FOR 'root' = PASSWORD('new-pass'); FLUSH PRIVILEGES;}
\cmd{\postgres}{ALTER USER root WITH PASSWORD 'new-pass';}
\cmd{\mssql}{ALTER LOGIN user WITH PASSWORD = 'pass'; GO;}
\end{action}
\begin{action}{Add/Delete user}
\cmd{\mysql}{CREATE USER 'user'@'localhost' IDENTIFIED BY 'pass';}
\cmd{\mysql}{DROP USER user;}
\cmd{\postgres}{CREATE USER user-name WITH PASSWORD 'pass' VALID UNTIL 'Jan 1 2014';}
\cmd{\postgres}{DROP USER user-name;}
\end{action}
\begin{action}{Permissions}
\cmd{\mysql}{GRANT ALL ON db1.* TO 'foo'@'localhost'; FLUSH PRIVILEGES;}
\cmd{\mysql}{GRANT SELECT ON db2.invoice TO 'bar'@'localhost'; FLUSH PRIVILEGES;}
\cmd{\mysql}{REVOKE ALL ON *.* TO 'bar'@'localhost'; FLUSH PRIVILEGES;}
\cmd{\postgres}{GRANT ALL PRIVILEGES ON *.* TO user;}
\cmd{\postgres}{REVOKE ALL PRIVILEGES ON *.* FROM user;}
\cmd{\mssql}{GRANT ALL PRIVILEGES ON *.* TO windows-db-user [WITH GRANT OPTION]; GO;}
\cmd{\mssql}{GRANT SELECT ON *.* TO user; GO;}
\cmd{\mssql}{USE db-name; REVOKE ALL PRIVILGES FROM user; GO;}
\cmd{\mssql}{USE db-name; REVOKE [GRANT OPTION FOR] ALTER FROM user; GO;}
\end{action}
\subsection*{Windows Tasks}
\begin{action}{Open Network Connections}
\cmd{\windows}{ncpa.cpl}
\end{action}
\begin{action}{Open Basic Firewall}
\cmd{\windows}{firewall.cpl}
\end{action}
\begin{action}{Open Advanced Firewall}
\cmd{\windows}{wf.msc}
\end{action}
\begin{action}{Open Internet Options}
\cmd{\windows}{inetcpl.cpl}
\end{action}
\begin{action}{Open Programs \& Features}
\cmd{\windows}{appwiz.cpl}
\end{action}
\begin{action}{Open Local User Manager}
\cmd{\windows}{lusrmgr.msc}
\end{action}
\begin{action}{Download file from Internet}
\cmd{\windows}{
Powershell \\
\$source = "http:www.download.com/file.txt" \\
\$destination = "c:\textbackslash temp\textbackslash file.txt" \\
\$wc = New-Object System.Net.WebClient \\
\$wc.DownloadFile(\$source, \$destination)}
\end{action}
\begin{action}{List device drivers and their properties}
\cmd{\windows}{driverquery (-v)}
\end{action}
\subsection*{OpenSSL Certificate Manipulation}
\begin{action}{Create a self-signed certificate}
\cmd{\unix}{openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout
priv.key -out cert.crt}
\end{action}
\begin{action}{Create a private key and CSR}
\cmd{\unix}{openssl req -out CSR.csr -new -newkey rsa:2048 -nodes -keyout
priv.key}
\end{action}
\begin{action}{Create CSR for an existing private key}
\cmd{\unix}{openssl req -out CSR.csr -key priv.key -new}
\end{action}
\begin{action}{Create a CSR for an existing certificate}
\cmd{\unix}{openssl x509 -x509toreq -in cert.crt -out CSR.csr
-signkey priv.key}
\end{action}
\begin{action}{Remove passphrase from a private key}
\cmd{\unix}{openssl rsa -in priv.pem -out new\_priv.pem}
\end{action}
\begin{action}{Inspect a CSR}
\cmd{\unix}{openssl req -text -noout -verify -in CSR.csr}
\end{action}
\begin{action}{Inspect a private key}
\cmd{\unix}{openssl rsa -in priv.key -check}
\end{action}
\begin{action}{Inspect a certificate}
\cmd{\unix}{openssl x509 -in cert.crt -text -noout}
\end{action}
\begin{action}{Inspect ASN.1 structure of a certificate}
\cmd{\unix}{openssl asn1parse -in cert.crt}
\end{action}
\begin{action}{Inspect a PKCS\#12 file (.pfx or .p12)}
\cmd{\unix}{openssl pkcs12 -info -in keyStore.p12}
\end{action}
\begin{action}{Connect to site and validate certificate chain}
\cmd{\unix}{openssl s\_client -showcerts -connect host:443}
\end{action}
\section*{References}
\begin{itemize}
\small
\item \url{http://bit.ly/cmd-line-kung-fu}
\item \url{http://bit.ly/useful-windows-one-liners}
\item \url{http://bit.ly/vmware-esxi-reference}
\item \url{http://bit.ly/ssl-commands}
\end{itemize}
\section*{Tool Downloads}
\begin{itemize}
\small
\item Sys Internals: \url{http://bit.ly/sys-internals}
\item Seconfig XP: \url{http://seconfig.sytes.net/}
\item EMET: \url{http://bit.ly/win-emet}
\end{itemize}
\end{multicols*}
\end{document}