Basic Setup

Minimal bits and pieces to make following the writeups a little easier.

Hosts File

While using HTB I have found it easier to add hostnames to /etc/hosts for machines such as machinename.htb. This makes it easier to define a machine when going back through commands rather than trying to remember which IP address is associated with a certain machine. You can checkout this gist for a ready-made hosts file or copy the contents below:

127.0.0.1       localhost
127.0.1.1       htb

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

# Active
10.10.10.196    ropetwo.htb
10.10.10.203    worker.htb
10.10.10.204    omni.htb
10.10.10.205    feline.htb
10.10.10.206    passage.htb
10.10.10.207    compromised.htb
10.10.10.208    crossfit.htb
10.10.10.209    doctor.htb
10.10.10.210    reel2.htb
10.10.10.211    jewel.htb
10.10.10.212    bucket.htb
10.10.10.213    apt.htb
10.10.10.214    time.htb
10.10.10.215    academy.htb
10.10.10.216    laboratory.htb
10.10.10.217    cereal.htb
10.10.10.218    luanne.htb
10.10.10.219    sharp.htb
10.10.10.220    ready.htb
10.10.10.221    attended.htb

# Retired
10.10.10.3      lame.htb
10.10.10.4      legacy.htb
10.10.10.5      devel.htb
10.10.10.6      popcorn.htb
10.10.10.7      beep.htb
10.10.10.8      optimum.htb
10.10.10.9      bastard.htb
10.10.10.10     tenten.htb
10.10.10.11     arctic.htb
10.10.10.13     cronos.htb
10.10.10.14     grandpa.htb
10.10.10.15     granny.htb
10.10.10.16     october.htb
10.10.10.17     brainfuck.htb
10.10.10.18     lazy.htb
10.10.10.20     sneaky.htb
10.10.10.21     joker.htb
10.10.10.22	europa.htb
10.10.10.24     haircut.htb
10.10.10.25     holiday.htb
10.10.10.27	calamity.htb
10.10.10.29     bank.htb
10.10.10.31	charon.htb
10.10.10.34	jail.htb
10.10.10.37	blocky.htb
10.10.10.40	blue.htb
10.10.10.43	nineveh.htb
10.10.10.46	apocalyst.htb
10.10.10.47	shrek.htb
10.10.10.48	mirai.htb
10.10.10.51	solidstate.htb
10.10.10.52	mantis.htb
10.10.10.55	kotarak.htb
10.10.10.56	shocker.htb
10.10.10.57	minion.htb
10.10.10.58	node.htb
10.10.10.59	tally.htb
10.10.10.60	sense.htb
10.10.10.61	enterprise.htb
10.10.10.62	fulcrum.htb
10.10.10.63	jeeves.htb
10.10.10.64	stratosphere.htb
10.10.10.65	ariekei.htb
10.10.10.66	nightmare.htb
10.10.10.67	inception.htb
10.10.10.68     bashed.htb
10.10.10.69	fluxcapacitor.htb
10.10.10.70	canape.htb
10.10.10.71	rabbit.htb
10.10.10.72	fighter.htb
10.10.10.73	falafel.htb
10.10.10.74	chatterbox.htb
10.10.10.75	nibbles.htb
10.10.10.76	sunday.htb
10.10.10.77	reel.htb
10.10.10.78	aragog.htb
10.10.10.79	valentine.htb
10.10.10.80	crimestoppers.htb
10.10.10.81	bart.htb
10.10.10.82	silo.htb
10.10.10.83	olympus.htb
10.10.10.84	poison.htb
10.10.10.85	celestial.htb
10.10.10.86	dab.htb
10.10.10.87	waldo.htb
10.10.10.88	tartarsauce.htb
10.10.10.89	smasher.htb
10.10.10.90	dropzone.htb
10.10.10.91	devoops.htb
10.10.10.92	mischief.htb
10.10.10.93	bounty.htb
10.10.10.94	reddish.htb
10.10.10.95	jerry.htb
10.10.10.96	oz.htb
10.10.10.97	secnotes.htb
10.10.10.98     access.htb
10.10.10.100	active.htb
10.10.10.101	ghoul.htb
10.10.10.102	hawk.htb
10.10.10.103	sizzle.htb
10.10.10.104	giddy.htb
10.10.10.105	carrier.htb
10.10.10.106	ethereal.htb
10.10.10.107	ypuffy.htb
10.10.10.108	zipper.htb
10.10.10.109	vault.htb
10.10.10.110    craft.htb
10.10.10.111	frolic.htb
10.10.10.112	bighead.htb
10.10.10.113	redcross.htb
10.10.10.114    bitlab.htb
10.10.10.115    haystack.htb
10.10.10.116	conceal.htb
10.10.10.117	irked.htb
10.10.10.119	lightweight.htb
10.10.10.120	chaos.htb
10.10.10.121	help.htb
10.10.10.122	ctf.htb
10.10.10.123	friendzone.htb
10.10.10.124	flujab.htb
10.10.10.125	querier.htb
10.10.10.126	unattended.htb
10.10.10.127	fortune.htb
10.10.10.128	hackback.htb
10.10.10.129	kryptos.htb
10.10.10.130	arkham.htb
10.10.10.131	lacasadepapel.htb
10.10.10.132	helpline.htb
10.10.10.133	onetwoseven.htb
10.10.10.134	bastion.htb
10.10.10.135	smasher2.htb
10.10.10.137	luke.htb
10.10.10.138	writeup.htb
10.10.10.139	ellingson.htb
10.10.10.140	swagshop.htb
10.10.10.142	chainsaw.htb
10.10.10.143	jarvis.htb
10.10.10.144    re.htb
10.10.10.145    player.htb
10.10.10.146    networked.htb
10.10.10.147	safe.htb
10.10.10.148    rope.htb
10.10.10.149    heist.htb
10.10.10.150	curling.htb
10.10.10.151    sniper.htb
10.10.10.152	netmon.htb
10.10.10.153	teacher.htb
10.10.10.154    bankrobber.htb
10.10.10.155    scavenger.htb
10.10.10.156    zetta.htb
10.10.10.157	wall.htb
10.10.10.158    json.htb
10.10.10.159    registry.htb
10.10.10.160    postman.htb
10.10.10.161    forest.htb
10.10.10.162    mango.htb
10.10.10.163    ai.htb
10.10.10.165    traverxec.htb
10.10.10.167    control.htb
10.10.10.168    obscurity.htb
10.10.10.169    resolute.htb
10.10.10.170    playertwo.htb
10.10.10.172    monteverde.htb
10.10.10.173    patents.htb
10.10.10.174    fatty.htb
10.10.10.175    sauna.htb
10.10.10.176    book.htb
10.10.10.177    oouch.htb
10.10.10.178    nest.htb
10.10.10.179    multimaster.htb
10.10.10.180    remote.htb
10.10.10.181	traceback.htb
10.10.10.182    cascade.htb
10.10.10.183    forwardslash.htb
10.10.10.184    servmon.htb
10.10.10.185    magic.htb
10.10.10.186    quick.htb
10.10.10.187    admirer.htb
10.10.10.188    cache.htb
10.10.10.189    travel.htb
10.10.10.190    dyplesher.htb
10.10.10.191    blunder.htb
10.10.10.192    blackfield.htb
10.10.10.193    fuse.htb
10.10.10.194    tabby.htb

Portscan

A simple bash script to grab open ports with nmap and then scan just those open ports more aggressively:

#!/bin/bash
echo Grabbing ports...
ports=$(nmap -p- --min-rate 1000 -T4 $1 | grep ^[0-9] | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//)  
echo Ports grabbed!
echo Scanning...
nmap -sC -sV -Pn -p $ports $1 $2 $3

Example:

portscan 192.168.0.1 -oX nmap.xml

Hack The Box