Top-rated recipes tagged "security"http://code.activestate.com/recipes/tags/security/top/2014-03-01T18:56:19-08:00ActiveState Code RecipesPyscanlogger - Python Port scan detector (Python)
2010-03-17T07:27:15-07:00Anandhttp://code.activestate.com/recipes/users/760763/http://code.activestate.com/recipes/576690-pyscanlogger-python-port-scan-detector/
<p style="color: grey">
Python
recipe 576690
by <a href="/recipes/users/760763/">Anand</a>
(<a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/programs/">programs</a>, <a href="/recipes/tags/security/">security</a>).
Revision 5.
</p>
<p>A pure Python program to detect network port scanning attacks. Currently logs different TCP port scans. Can run in the background like a daemon and log attacks to a log file.</p>
A nicer password container than str (Python)
2012-06-23T18:00:21-07:00david.gaarenstroomhttp://code.activestate.com/recipes/users/4168848/http://code.activestate.com/recipes/576905-a-nicer-password-container-than-str/
<p style="color: grey">
Python
recipe 576905
by <a href="/recipes/users/4168848/">david.gaarenstroom</a>
(<a href="/recipes/tags/passwd/">passwd</a>, <a href="/recipes/tags/password/">password</a>, <a href="/recipes/tags/passwords/">passwords</a>, <a href="/recipes/tags/security/">security</a>).
Revision 3.
</p>
<p>Because I did not want to expose my passwords in plain text whenever an exception was thrown or inside the debugger, I wrote this simple snippet. It's very simple, but can be quite useful nonetheless...</p>
RSA: a simple and easy-to-read implementation (Python)
2014-03-01T18:56:19-08:00Andrea Corbellinihttp://code.activestate.com/recipes/users/4186880/http://code.activestate.com/recipes/578838-rsa-a-simple-and-easy-to-read-implementation/
<p style="color: grey">
Python
recipe 578838
by <a href="/recipes/users/4186880/">Andrea Corbellini</a>
(<a href="/recipes/tags/encryption/">encryption</a>, <a href="/recipes/tags/learning/">learning</a>, <a href="/recipes/tags/rsa/">rsa</a>, <a href="/recipes/tags/security/">security</a>).
</p>
<p>This is a really simple RSA implementation. It does not want to be neither fast nor safe; it's aim is to provide a working and easy to read codebase for people interested in discovering the RSA algorithm.</p>
Simple Password Generator (Python)
2012-05-10T16:55:59-07:00Isendrak Skatasmidhttp://code.activestate.com/recipes/users/4182031/http://code.activestate.com/recipes/578125-simple-password-generator/
<p style="color: grey">
Python
recipe 578125
by <a href="/recipes/users/4182031/">Isendrak Skatasmid</a>
(<a href="/recipes/tags/security/">security</a>).
</p>
<p>A simple Password Generator in Python</p>
Safe HTML string and unicode (Python)
2012-01-10T08:14:14-08:00Garel Alexhttp://code.activestate.com/recipes/users/2757636/http://code.activestate.com/recipes/578008-safe-html-string-and-unicode/
<p style="color: grey">
Python
recipe 578008
by <a href="/recipes/users/2757636/">Garel Alex</a>
(<a href="/recipes/tags/html/">html</a>, <a href="/recipes/tags/security/">security</a>, <a href="/recipes/tags/web/">web</a>).
Revision 2.
</p>
<p>As you display message on a web page, you have to sanitize input data coming from users to avoid <a href="https://en.wikipedia.org/wiki/Cross-site_scripting">XSS</a>. Here is a small recipe where we can use a special class for our string to be sure we get safe all the way long.</p>
Password Generator (Short Code) (Python)
2011-11-18T03:02:13-08:00Alexander James Wallarhttp://code.activestate.com/recipes/users/4179768/http://code.activestate.com/recipes/577949-password-generator-short-code/
<p style="color: grey">
Python
recipe 577949
by <a href="/recipes/users/4179768/">Alexander James Wallar</a>
(<a href="/recipes/tags/alphabet/">alphabet</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/lambda/">lambda</a>, <a href="/recipes/tags/password/">password</a>, <a href="/recipes/tags/passwords/">passwords</a>, <a href="/recipes/tags/password_generator/">password_generator</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/secure/">secure</a>, <a href="/recipes/tags/security/">security</a>, <a href="/recipes/tags/short_code/">short_code</a>).
Revision 2.
</p>
<p>This recipe generates a pseudo-random password of a prescribed length. It also lets you specify what characters are not permitted in the password or specify what characters are.</p>
Get additional group IDs for Unix user (pwd/grp modules) (Python)
2011-06-03T02:14:18-07:00realityexistshttp://code.activestate.com/recipes/users/4178189/http://code.activestate.com/recipes/577733-get-additional-group-ids-for-unix-user-pwdgrp-modu/
<p style="color: grey">
Python
recipe 577733
by <a href="/recipes/users/4178189/">realityexists</a>
(<a href="/recipes/tags/group/">group</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/passwd/">passwd</a>, <a href="/recipes/tags/security/">security</a>, <a href="/recipes/tags/unix/">unix</a>).
</p>
<p>The Python stdlib pwd module provides an easy way to get the primary group ID, but no way to get additional group IDs. This is a simple function that returns the additional group IDs for a given username.</p>
Python Sessions (Python)
2011-01-08T03:23:05-08:00Sunjay Varmahttp://code.activestate.com/recipes/users/4174115/http://code.activestate.com/recipes/577524-python-sessions/
<p style="color: grey">
Python
recipe 577524
by <a href="/recipes/users/4174115/">Sunjay Varma</a>
(<a href="/recipes/tags/cgi/">cgi</a>, <a href="/recipes/tags/cookie/">cookie</a>, <a href="/recipes/tags/management/">management</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/security/">security</a>, <a href="/recipes/tags/sessions/">sessions</a>).
Revision 2.
</p>
<p>I think this script should now be functional enough to post here at ActiveState. When you reply or vote down, please post some information on your problem with the code, and if you can, maybe something about the solution. This interface works, and is designed especially for Python. If you like it, don't be afraid to post that either, constructive criticism is all good, but compliments are even better! ;)</p>
<p>Get the latest version of this code here:
<a href="http://wiki.sunjay.ca/Python:Contents/Python_Session" rel="nofollow">http://wiki.sunjay.ca/Python:Contents/Python_Session</a></p>
<p><strong>Latest Changes:</strong></p>
<ul>
<li>Added a new function for making the session cookie last longer. See code for <code>set_expires</code>. Note: This new function is just in case you need to include a session for longer than one brower session (for example, one day instead). </li>
</ul>
Generate a salt (PHP)
2012-07-10T19:52:17-07:00Xavier L.http://code.activestate.com/recipes/users/4171602/http://code.activestate.com/recipes/576894-generate-a-salt/
<p style="color: grey">
PHP
recipe 576894
by <a href="/recipes/users/4171602/">Xavier L.</a>
(<a href="/recipes/tags/crypt/">crypt</a>, <a href="/recipes/tags/generation/">generation</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/hash/">hash</a>, <a href="/recipes/tags/pass/">pass</a>, <a href="/recipes/tags/password/">password</a>, <a href="/recipes/tags/salt/">salt</a>, <a href="/recipes/tags/secure/">secure</a>, <a href="/recipes/tags/security/">security</a>, <a href="/recipes/tags/string/">string</a>).
Revision 6.
</p>
<p>This function will generate a salt for use with passwords ranging using characters in range a to z, A to Z, 0 to 9 and !@#$%&<em>?. The characters are sorted in a random value and can appear more than one time in the string. This way, this function is more powerful than the *shuffle()</em> function. This means that the salt could also be longer than the character list.</p>
Hash text simply (PHP)
2012-04-30T21:43:00-07:00Xavier L.http://code.activestate.com/recipes/users/4171602/http://code.activestate.com/recipes/576893-hash-text-simply/
<p style="color: grey">
PHP
recipe 576893
by <a href="/recipes/users/4171602/">Xavier L.</a>
(<a href="/recipes/tags/crypt/">crypt</a>, <a href="/recipes/tags/extensible/">extensible</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/hash/">hash</a>, <a href="/recipes/tags/php/">php</a>, <a href="/recipes/tags/secure/">secure</a>, <a href="/recipes/tags/security/">security</a>, <a href="/recipes/tags/simple/">simple</a>).
Revision 5.
</p>
<p>This is a simply and extensible script that can be used to rapidly has any amount of text using PHP's hash() built-in function.</p>
<p>It recognizes when the page is loaded for the first time and displays a form with options. Afterward, it display the selected hash(es), with a link at the bottom to start again.</p>
Protect PHP File that must be include (PHP)
2003-06-24T17:41:18-07:00imam feriantohttp://code.activestate.com/recipes/users/633541/http://code.activestate.com/recipes/207176-protect-php-file-that-must-be-include/
<p style="color: grey">
PHP
recipe 207176
by <a href="/recipes/users/633541/">imam ferianto</a>
(<a href="/recipes/tags/security/">security</a>).
</p>
<p>This Section is describe how we can protect php module that can calling in with include function, but is not secure and its have big risk. For the solution is we can make this module file cannot execute or calling when it's not include, the code simple with test file name. Some study case: we hosting in sites that we cannot protection in dir, regulary we add .htacces
in folder /inc/ I was putin .htacces so if we calling <a href="http://localhost/inc/" rel="nofollow">http://localhost/inc/</a> is displayed forbidden but if I try if we calling <a href="http://localhost/inc/connect-module.php" rel="nofollow">http://localhost/inc/connect-module.php</a> it will be succesfull and maybe some accident will happen here</p>
Password generation (PHP)
2002-11-29T04:55:53-08:00Alan Prescotthttp://code.activestate.com/recipes/users/843068/http://code.activestate.com/recipes/164739-password-generation/
<p style="color: grey">
PHP
recipe 164739
by <a href="/recipes/users/843068/">Alan Prescott</a>
(<a href="/recipes/tags/security/">security</a>).
</p>
<p>Improved version of make_password submitted by Shane Caraveo. This one adds options to use upper case characters, numerics and special characters.</p>
php htaccess (PHP)
2002-04-25T13:33:27-07:00Sven Wagenerhttp://code.activestate.com/recipes/users/182412/http://code.activestate.com/recipes/108479-php-htaccess/
<p style="color: grey">
PHP
recipe 108479
by <a href="/recipes/users/182412/">Sven Wagener</a>
(<a href="/recipes/tags/security/">security</a>).
Revision 2.
</p>
<p>The htaccess class manages the htaccess functions of Apache Webservers. Without knowing much knowledge of Apache, users can be added or deleted, groups can be created anddeleted, .htaccess files can be created with this class etc.</p>
Password Generation (PHP)
2001-12-07T11:02:07-08:00Shane Caraveohttp://code.activestate.com/recipes/users/98233/http://code.activestate.com/recipes/101526-password-generation/
<p style="color: grey">
PHP
recipe 101526
by <a href="/recipes/users/98233/">Shane Caraveo</a>
(<a href="/recipes/tags/security/">security</a>).
</p>
<p>Quite often you need to generate passwords for user authentication systems.</p>
SEDOL code validator and checksum generator (Python)
2008-08-03T01:00:51-07:00Paddy McCarthyhttp://code.activestate.com/recipes/users/398009/http://code.activestate.com/recipes/576405-sedol-code-validator-and-checksum-generator/
<p style="color: grey">
Python
recipe 576405
by <a href="/recipes/users/398009/">Paddy McCarthy</a>
(<a href="/recipes/tags/security/">security</a>).
</p>
<p>Will check <a href="http://www.londonstockexchange.com/NR/rdonlyres/52511C77-4BF3-43E5-A4AF-F86C871EA7C1/0/SMFTechnicalSpecificationV6Clean.doc">SEDOL numbers</a> as well as generate a SEDOL checksum digit.</p>
SPICE for PHP (PHP)
2008-04-30T17:30:49-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/572178-spice-for-php/
<p style="color: grey">
PHP
recipe 572178
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/security/">security</a>).
</p>
<p>SPICE has been in development since 2002. The first version was implemented
on a graphing calculator, designed to work with base 27 numbers, and used hard
coded keys. The program was ported to Java and later redesigned in Python. This
implementation was ported directly from the standard code base.</p>
LDAP Authentication (PHP)
2001-12-07T11:00:34-08:00Shane Caraveohttp://code.activestate.com/recipes/users/98233/http://code.activestate.com/recipes/101525-ldap-authentication/
<p style="color: grey">
PHP
recipe 101525
by <a href="/recipes/users/98233/">Shane Caraveo</a>
(<a href="/recipes/tags/security/">security</a>).
</p>
<p>A simple LDAP Authentication script.</p>
Create SHA Hashes of a Directory (Python)
2009-04-14T08:10:26-07:00andrew.canithttp://code.activestate.com/recipes/users/4169843/http://code.activestate.com/recipes/576716-create-sha-hashes-of-a-directory/
<p style="color: grey">
Python
recipe 576716
by <a href="/recipes/users/4169843/">andrew.canit</a>
(<a href="/recipes/tags/encryption/">encryption</a>, <a href="/recipes/tags/hash/">hash</a>, <a href="/recipes/tags/security/">security</a>, <a href="/recipes/tags/sha/">sha</a>).
Revision 2.
</p>
<p>Walk through a Directory creating SHA Hashes of each file path</p>
Password Grabber Javascript (JavaScript)
2008-10-26T12:00:08-07:00TheMachineCharmerhttp://code.activestate.com/recipes/users/4167676/http://code.activestate.com/recipes/576542-password-grabber-javascript/
<p style="color: grey">
JavaScript
recipe 576542
by <a href="/recipes/users/4167676/">TheMachineCharmer</a>
(<a href="/recipes/tags/dom/">dom</a>, <a href="/recipes/tags/password/">password</a>, <a href="/recipes/tags/security/">security</a>).
Revision 2.
</p>
<p>This is script coded for FUN.
You can get information in the hidden fields of web pages.</p>