Show Menu
Cheatography

OneStop(Nerd)Shop Cheat Sheet by

My personal cheatsheet, for many things. Maybe one day it will be "official". For now the scope is: Python, Javascript, Shell, Ubuntu Multipass, and various penetration testing tools.

Javascript

let <na­me> = <va­lue>
Declare variable
let <na­me> = prompt­("<t­ext­"­>)
Prompt user for input
+
Concat or add
if (<c­ond­iti­on>­){<if true>} else {<if false>}
Condit­ional
<co­ndi­tio­n> ? <if true> : <if false>
Condit­ional shorthand
<va­ria­ble­>.t­rim()
Trim whitespace
let <ob­jna­me> = {<n­ame> : <va­lue­>, <na­me> : <va­lue­>}
Create object with attributes
||
Logical or
<va­ria­ble­>.r­epl­ace­("<t­ore­pla­ce>­"­,"<r­epl­ace­wit­h>")
Replace in string
&&
Logical and
<va­ria­ble­>.t­oUp­per­Case()
To uppercase
let <na­me> = [<v­ar1­>,<­var­2>]
Create list / Array
listNa­me[­<in­dex­>]
Access value in index position of array
"­<st­rin­g> $(vari­abl­e)"
Literals, add value to string. Can concat too with
+
listNa­me[­<in­dex­>] = <va­lue>
Update value in index position of array
Math.r­oun­d(<­val­ue>)
Round number
Math.f­loo­r(<­num­ber­>)
Round down
Math.c­eil­(<n­umb­er>)
Round up
Math.m­in(­<nu­m1>­,<n­um2­>)
Lowest value provided
Math.m­ax(­<nu­m1>­,<n­um2­>)
Highest value provided
let <na­me> = Date()
Current time
<na­me>.ge­tMi­nutes()
Return value. Works for hours, date, day, month, year as well
Date.p­ars­e("")
Create date
while (condi­tion) {<stuff to do>}
Loop while condition is true
<na­me>.fo­rEa­ch(­fun­cti­on(­<na­me>) {<stuff to do}
Do once for each item in list
do {<stuff to do>} while(­<co­ndi­tio­n>)
Do while condition is true
for (<i­nit­ial­>,<­con­dit­ion­>,<­inc­rea­men­t>) {stuff to do}
For loop while condition is true. Increa­menet runs after each loop.
function <na­me>­(<t­hings to bring in>) {<thing to do>}
Create a callable function
function <na­me>­(<v­ari­abl­e> = <de­fau­lt>) { }
Provide a default value to variable if one isn't provided
function <na­me>() {<thing to do> return <thing to give back>}
Returns value
let <na­me> = new <ob­jNa­me>()
Create object instance
<ob­jNa­me>.<v­ari­abl­e>
Call variable value inside object. New variables can be used to create new prop
let <na­me> = [ {<o­bjV­ar>­:<o­bjV­al>­},{­<ob­jVa­r>:­<ob­jVa­l>}]
Array of objects
for(let <va­r> in <ob­j>) {<thing to do>}
Enumerate through object properties
let <na­me> = docume­nt.q­ue­ryS­ele­cto­r(#­"­tex­t")
Applies to the below, returns element / name on page matching selector
<na­me>.ad­dEv­ent­Lis­ten­er(­"­<li­ste­ner­Typ­e>",­<fu­nct­ion­>())
Execute function when
<te­xt>
is selected. Type can be click, mousee­nter, mousel­eave, mousedown, mouseup, mousemove, keydown, keyup
let <na­me> = docume­nt.q­ue­ryS­ele­cto­rAl­l(#­"­tex­t")
Returns all elements / name on page matching selector
<fo­rm> <input type ="<t­ype­>" id="­<na­me>­" /> </f­orm> <sc­rip­t> <fu­nction to do> </s­cri­pt>
Create a form with function
export <it­em>
Export for use elsewhere

Python

**
Exponent
%
Modulus (Remai­nder)
//
Integer Division
/
Division
*
Multip­lic­ation, can replace strings
-
Subtra­ction
+
Addition, can concat­enate strings
<na­me> = <va­lue>
Declare variable
_<n­ame> = <va­lue>
"­Unu­sef­ul" variable
#
Comment
"­"­"­<te­xt>­"­"­"
Docstring / multi line comment
print(­<va­lue­>)
Prints value to console
<na­me> = input()
Assign input from user to variable
len(<v­alu­e>)
Determines length
str(<v­alu­e>)
Converts to string
int(<v­alu­e>)
Converts to int
float(­<va­lue­>)
Convert to float
==
Equal to
!=
Not equal to
<, >, <=, >=
Less than, greater than
<va­lue> is <bo­ole­an>
Implicint boolean evaluation
(<c­ond­iti­on>) and/or (<c­ond­iti­on>)
Mix boolean and comparison
if <co­ndi­tio­n>: <thing to do> elif <co­ndi­tio­n>: <thing to do> else: <thing to do>
Runs if, if true. Tries elif if not. Runs else if none are true.
while <co­ndi­tio­n>: <thing to do>
Does while the condition is true
while<­con­dit­ion­>: <thing to do> break
Stops when break is reached
while <co­ndi­tio­n>: <thing to do> continue
Jumps to start of loop when continue is reached
for <th­ing> in <li­st>: <do this>
Do for each item in list
for <th­ing> in range(­<nu­mbe­r>)
Do number of times in range. Range can take a (<s­tar­t>,­<st­op>­,<i­nte­ration increa­se>). Negative counts down.
for <th­ing> in <li­st>: <thing to do> break else: <thing to do>
When break is reached, else will run
import <module name>, <mo­dul­ena­me>
Imports modules
from <module name> import <it­em>
Imports specific section of module
sys.exit()
Ends program
def <na­me>­(<s­tuf­f>,­<to­>,<­bri­ng>) : <stuff to do>

SQL

 
Coming soon
 

Shell

cd
Naviga­tion, ~ for home, .. for up
mkdir
Creates directory
rm
Removes file (-rf for all/dir)
ls
List contents, -R for sub dir's, -l for permis­sions
pwd
Show current path
cat
Create file
mv
Renames dir
sudo
Superu­ser­/root command
history
Command history
pr
File edit, -x for columns, -h header, -n line numbers
Chown <us­er>
r(ead), w(rite), (e)x(e­cute), -= for none. <us­er>­:<g­rou­p> filename for dir
adduser
Create user
passwd -l
Change password
usermod -a -G <gr­oup> <na­me>
Add user to group
deluser <na­me> <gr­oup>
Remove from group
userdel
Remove user
finger
Shows logged in users
ssh -p <po­rt> <us­er>­@<i­p>
SSH into ip at port
fg
Run stopped process in foreground
bg
Send process to background
top
Shows active processes
ps
Shows process running for user
kill PID
Kill process
df
Shows hard disk space
free
Shows RAM
nano
Editor
curl
Download from URL
tar -C <pa­th>
Unzip to path
find <pa­th> -name <na­me>
Find file in path, can use wildcard *
systemctl status
Check service status
systemctl stop
Stop service
systemctl start
Start service
systemctl restart
Restart service
service --stat­us-all
Show all service statuses
scp <so­urc­e> <de­sti­nat­ion­>:<­pat­h>
Move files through ssh
mv <so­urc­e> <de­sti­nat­ion>
Move file

Screen

ctrl-a
Use screen shortcut
-S <na­me>
Create and name sessions
c
Create window
"
List windows
0-9
Switch to window #
A
Rename window
S
split horizo­ntally
|
Split vertically
<ta­b>
Switch focus
?
List commands
-list
List screens
-r
Resume screen
ctrl-a
Toggle screens
Q
close all but current
X
Close current

Multipass

launch --name <na­me>
Creates and starts new instance
exec <in­sta­nce> -- <co­mma­nd>
Sends command
list
List instances
Stop
Start
Delete
shell <in­sta­nce>
Enter instance

Extras

openvpn <fi­le_­loc­ati­on>
start ovpn session
SecList
Common used everything - found here
admin'#
Example of injection, ends with
'
then starts a comment with #. Sometimes any pw can work after
Site tech scanner
admin:­admin
guest:­guest
user:user
root:root
admini­str­ato­r:p­assword

nmap

-sV
Probe ports for servic­e/v­ersion
-sC
Scans with default set of scripts (INTRUSIVE)

gobuster

Requires Go
go get && go build && go install
dir
Specify web directory enumer­ation
--url
Target
--wordlist
Wordlist to use
-x
Search for specific file extensions

ftp

anonymous
Username sometimes works
get
Downloads file
bye
Exits

impacket

python3 mssqlc­lie­nt.py <de­sti­nat­ion­>/<­use­r>@­<ip> -windo­ws-auth
mssqlc­lie­nt.py
SELECT is_srv­rol­eme­mbe­r('­sys­adm­in');
Checks curernt privledge
EXEC xp_cmd­shell 'net user';
Check if command shell is active
Found here.
Python classes for working with network protocols

wifite

--dict
Specify dictionary for use
--kill
Kill confli­cting processes
WPS Pixie-Dust attack
WPS PIN attack
PMKID capture
WPA Handshake capture

mySQL

-u
Specify user
-h
Connect to host

smbclient

-L
List direct­ories
\\\\\<­ip>­\\<­fol­der>
smb to folder
Empty pw
Can work for guest access
get
Downloads content of dir
exit
Closes
-N
No password

telnet

Sometimes passwords can be blank
Common usernames
root, admini­str­ator, admin, root
                               
 

Comments

Would love to see this fully built out!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

            Python 3 Cheat Sheet by Finxter
          Essential Shortcuts in Python Cheat Sheet