Skip to content

Instantly share code, notes, and snippets.

@freretuc
freretuc / lib.otp.php
Created April 6, 2015 08:39
give a secret and a time and its return the current TOTP.
<?php
function getOTP($secret, $time) {
$counter = floor($time/30);
$arr_map = array_flip(str_split("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"));
$arr_secret = str_split(preg_replace('/[^A-Z2-7]/', '', strtoupper($secret)));
$bin_secret = "";
https://s3.amazonaws.com/webdigi/VPN/Unified-Cloud-Formation.json
You can verify which Active Directory users and groups have been imported to the FreeNAS® system by using these commands within the FreeNAS® Shell. To view users:
wbinfo -u
To view groups, use:
wbinfo -g
https://forums.freenas.org/index.php?threads/how-to-properly-setup-freenas-to-use-active-directory-folder-file-user-permissions.20610/
@freretuc
freretuc / distro.py
Created January 11, 2015 19:04
get distro
def getDistro():
os.system("cat /etc/*release > getdistro")
file = open("getdistro", "r")
content = ''.join(file.readlines())
file.close()
os.remove("getdistro")
_os = "undef"
_ver = "undef"
@freretuc
freretuc / ssl.conf
Created January 11, 2015 07:38
apache ssl vhost
<VirtualHost _default_:443>
ServerAdmin [email protected]
ServerName your_domain.com
ServerAlias *.your_domain.com
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
@freretuc
freretuc / gist:013b68053cd07138754a
Created January 11, 2015 07:36
convert crt to pem
openssl x509 -in mycert.crt -out mycert.pem -outform PEM
@freretuc
freretuc / gist:a48761a5d387b023d2ee
Created January 10, 2015 09:06
Unix : lost mysql root password
/etc/init.d/mysql stop
echo "UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; FLUSH PRIVILEGES;" >> /home/mysql-init
mysqld_safe --init-file=/home/mysql-init &
rm /home/mysql-init
/etc/init.d/mysql stop
/etc/init.d/mysql start
or
/etc/init.d/mysql stop
@freretuc
freretuc / gist:b3d917dde363fbd83de2
Last active August 29, 2015 14:13
generate && add ssh key
Client
ssh-keygen -t rsa
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub --> copy
Client (to automatically remain the passphrase)
@freretuc
freretuc / gist:9b0dbbd348d8de210f4c
Created January 8, 2015 15:47
sftp configuration
nano /etc/ssh/sshd_config
Match Group sftp
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no
close
service ssh restart
<?php
function base32_decode($data) {
$base = array_flip(array_merge(range("A","Z"), range("2", "7")));
$array = str_split(strtoupper($data));
$n = 0;
$j = 0;
$binary = "";