Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

PHP

Social sharing links, properly sanitized

1
2
3
4
5
6
7
<?php
$share_title = get_the_title();
$share_link  = get_permalink();
?>
<a href="http://www.facebook.com/sharer.php?u=<?php echo urlencode($share_link); ?>" class="share-link facebook" target="_blank"><?php get_inline_svg('icon-social-facebook-f.svg'); ?><span class="screen-reader-text">Share on Facebook</span></a>
<a href="https://twitter.com/intent/tweet?url=<?php echo urlencode($share_link); ?>&amp;via=vital_design&amp;text=<?php echo esc_attr($share_title); ?>" class="share-link twitter" target="_blank"><?php get_inline_svg('icon-social-twitter.svg'); ?><span class="screen-reader-text">Share on Twitter</span></a>
<a href="mailto:?subject=<?php echo esc_attr($share_title); ?>&body=<?php echo esc_attr($share_title); ?>%0A<?php echo esc_url($share_link); ?>" class="share-link email"><?php get_inline_svg('icon-social-email.svg'); ?><span class="screen-reader-text">Share via Email</span></a>
https://snipt.net/embed/9b7efb032b0042ce48cd398c504f7ed8/
https://snipt.net/raw/9b7efb032b0042ce48cd398c504f7ed8/
9b7efb032b0042ce48cd398c504f7ed8
php
PHP
7
2016-12-02T12:10:43
True
False
False
Aug 12, 2016 at 04:05 PM
/api/public/snipt/147552/
social-sharing-links-properly-sanitized
<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> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="nv">$share_title</span> <span class="o">=</span> <span class="nx">get_the_title</span><span class="p">();</span> </span><span id="L-3"><a name="L-3"></a><span class="nv">$share_link</span> <span class="o">=</span> <span class="nx">get_permalink</span><span class="p">();</span> </span><span id="L-4"><a name="L-4"></a><span class="cp">?&gt;</span><span class="x"></span> </span><span id="L-5"><a name="L-5"></a><span class="x">&lt;a href=&quot;http://www.facebook.com/sharer.php?u=</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nb">urlencode</span><span class="p">(</span><span class="nv">$share_link</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">&quot; class=&quot;share-link facebook&quot; target=&quot;_blank&quot;&gt;</span><span class="cp">&lt;?php</span> <span class="nx">get_inline_svg</span><span class="p">(</span><span class="s1">&#39;icon-social-facebook-f.svg&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">&lt;span class=&quot;screen-reader-text&quot;&gt;Share on Facebook&lt;/span&gt;&lt;/a&gt;</span> </span><span id="L-6"><a name="L-6"></a><span class="x">&lt;a href=&quot;https://twitter.com/intent/tweet?url=</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nb">urlencode</span><span class="p">(</span><span class="nv">$share_link</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">&amp;amp;via=vital_design&amp;amp;text=</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nx">esc_attr</span><span class="p">(</span><span class="nv">$share_title</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">&quot; class=&quot;share-link twitter&quot; target=&quot;_blank&quot;&gt;</span><span class="cp">&lt;?php</span> <span class="nx">get_inline_svg</span><span class="p">(</span><span class="s1">&#39;icon-social-twitter.svg&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">&lt;span class=&quot;screen-reader-text&quot;&gt;Share on Twitter&lt;/span&gt;&lt;/a&gt;</span> </span><span id="L-7"><a name="L-7"></a><span class="x">&lt;a href=&quot;mailto:?subject=</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nx">esc_attr</span><span class="p">(</span><span class="nv">$share_title</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">&amp;body=</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nx">esc_attr</span><span class="p">(</span><span class="nv">$share_title</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">%0A</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nx">esc_url</span><span class="p">(</span><span class="nv">$share_link</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">&quot; class=&quot;share-link email&quot;&gt;</span><span class="cp">&lt;?php</span> <span class="nx">get_inline_svg</span><span class="p">(</span><span class="s1">&#39;icon-social-email.svg&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">&lt;span class=&quot;screen-reader-text&quot;&gt;Share via Email&lt;/span&gt;&lt;/a&gt;</span> </span></pre></div> </td></tr></table>
sanitize, security, share, social, validate

Bash

fail2ban show banned ips

# display banned ip for ssh service
fail2ban-client status ssh-iptables
https://snipt.net/embed/2a4593f95017f5a6649ba0c06fb75f3d/
https://snipt.net/raw/2a4593f95017f5a6649ba0c06fb75f3d/
2a4593f95017f5a6649ba0c06fb75f3d
bash
Bash
2
2016-12-03T00:47:08
True
False
False
Mar 31, 2015 at 10:20 AM
/api/public/snipt/138797/
fail2ban-show-banned-ips-03e1cae8
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</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"># display banned ip for ssh service</span> </span><span id="L-2"><a name="L-2"></a>fail2ban-client status ssh-iptables </span></pre></div> </td></tr></table>
centos, fail2ban, security

Bash

nmap centos

1
2
3
4
5
# Voir tous les ports TCP ouverts sur une machine, utilisation de messages SYN, donc pas de log sur la machine cible :
nmap -F -n -sS 127.0.0.1

# Voir tous les ports UDP ouverts sur une machine :
nmap -sU 127.0.0.1
https://snipt.net/embed/ae3a46c01b364683dcf3f7e5aef3f3df/
https://snipt.net/raw/ae3a46c01b364683dcf3f7e5aef3f3df/
ae3a46c01b364683dcf3f7e5aef3f3df
bash
Bash
5
2016-12-02T10:38:45
True
False
False
/api/public/snipt/138795/
namp-centos-18fbc7fe
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1"># Voir tous les ports TCP ouverts sur une machine, utilisation de messages SYN, donc pas de log sur la machine cible :</span> </span><span id="L-2"><a name="L-2"></a>nmap -F -n -sS 127.0.0.1 </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1"># Voir tous les ports UDP ouverts sur une machine :</span> </span><span id="L-5"><a name="L-5"></a>nmap -sU 127.0.0.1 </span></pre></div> </td></tr></table>
centos, nmap, security

Text only

Secure File Deletion on OS X

1
2
3
On the Mac, just use the menu 〖Finder▸Secure Empty Trash〗.

The command line equivalent is “srm”. Like this: srm -r -s dir_path. The “-r” means all content in the dir, including sub dir. The “-s” means just overwrite once.
https://snipt.net/embed/b58c84add6d808bc1e140dcada0074e2/
https://snipt.net/raw/b58c84add6d808bc1e140dcada0074e2/
b58c84add6d808bc1e140dcada0074e2
text
Text only
4
2016-12-02T12:28:18
True
False
False
Dec 06, 2012 at 06:58 PM
/api/public/snipt/51372/
secure-file-deletion-on-os-x
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>On the Mac, just use the menu 〖Finder▸Secure Empty Trash〗. </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>The command line equivalent is “srm”. Like this: srm -r -s dir_path. The “-r” means all content in the dir, including sub dir. The “-s” means just overwrite once. </span></pre></div> </td></tr></table>
osx, security

Text only

Prevent External POST or GET requests

1
2
3
4
//check to see if a HTTP_REFERER is set and if it is that it is equal to your website
if( !isset( $_SERVER['HTTP_REFERER']) || !strpos($_SERVER['HTTP_REFERER'],'example.com')) {
	exit;
}
https://snipt.net/embed/1f4ef70fd3177c7df7fd1f3677fd942f/
https://snipt.net/raw/1f4ef70fd3177c7df7fd1f3677fd942f/
1f4ef70fd3177c7df7fd1f3677fd942f
text
Text only
4
2016-12-02T23:49:31
True
False
False
Aug 27, 2012 at 12:45 PM
/api/public/snipt/46343/
prevent-external-post-or-get-requests
<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>//check to see if a HTTP_REFERER is set and if it is that it is equal to your website </span><span id="L-2"><a name="L-2"></a>if( !isset( $_SERVER[&#39;HTTP_REFERER&#39;]) || !strpos($_SERVER[&#39;HTTP_REFERER&#39;],&#39;example.com&#39;)) { </span><span id="L-3"><a name="L-3"></a> exit; </span><span id="L-4"><a name="L-4"></a>} </span></pre></div> </td></tr></table>
XSS, ajax, php, security
Copyrighted, illegal, or inappropriate content? Email [email protected].