snipt

Ctrl+h for KB shortcuts

Bash

infinite netcat

while true; do echo 'hello world' | netcat -l 80; done
https://snipt.net/embed/357df2b5856d7315e30f1650bf9b6c5d/
/raw/357df2b5856d7315e30f1650bf9b6c5d/
357df2b5856d7315e30f1650bf9b6c5d
bash
Bash
1
2019-05-16T11:46:05
True
False
False
Sep 23, 2013 at 05:07 PM
/api/public/snipt/82705/
infinite-netcat
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">while</span> true<span class="p">;</span> <span class="k">do</span> <span class="nb">echo</span> <span class="s1">&#39;hello world&#39;</span> <span class="p">|</span> netcat -l 80<span class="p">;</span> <span class="k">done</span> </span></pre></div> </td></tr></table>
bash, netcat

Python

netcat automatic reconnect

1
2
3
4
5
6
#!/usr/bin/env python2

import subprocess

while True:
    subprocess.call(['nc', 'localhost', '5206'])
https://snipt.net/embed/ba861c3055173a51f226e9a0cb10657d/
/raw/ba861c3055173a51f226e9a0cb10657d/
ba861c3055173a51f226e9a0cb10657d
python
Python
6
2019-05-16T09:36:00
True
False
False
/api/public/snipt/26983/
netcat-automatic-reconnect
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="ch">#!/usr/bin/env python2</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="kn">import</span> <span class="nn">subprocess</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="k">while</span> <span class="bp">True</span><span class="p">:</span> </span><span id="L-6"><a name="L-6"></a> <span class="n">subprocess</span><span class="o">.</span><span class="n">call</span><span class="p">([</span><span class="s1">&#39;nc&#39;</span><span class="p">,</span> <span class="s1">&#39;localhost&#39;</span><span class="p">,</span> <span class="s1">&#39;5206&#39;</span><span class="p">])</span> </span></pre></div> </td></tr></table>
nc, netcat, python, reconnect, restart

Bash

dump a database on one server and load it on another

1
2
3
4
# server
mysqldump -u<user> -p<pass> database | nc -l -p <port>
# client
nc <server> <port> | mysql -u<user> -p<pass> database
https://snipt.net/embed/c4801dc7574c2138cf8c0d8ccbac5042/
/raw/c4801dc7574c2138cf8c0d8ccbac5042/
c4801dc7574c2138cf8c0d8ccbac5042
bash
Bash
4
2019-05-21T18:36:55
True
False
False
/api/public/snipt/3695/
dump-a-database-on-one-server-and-load-it-on-another
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1"># server</span> </span><span id="L-2"><a name="L-2"></a>mysqldump -u&lt;user&gt; -p&lt;pass&gt; database <span class="p">|</span> nc -l -p &lt;port&gt; </span><span id="L-3"><a name="L-3"></a><span class="c1"># client</span> </span><span id="L-4"><a name="L-4"></a>nc &lt;server&gt; &lt;port&gt; <span class="p">|</span> mysql -u&lt;user&gt; -p&lt;pass&gt; database </span></pre></div> </td></tr></table>
mysql, netcat