Skip to content

Instantly share code, notes, and snippets.

Zibri Zibri

Block or report user

Report or block Zibri

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Zibri
Zibri / gitclean.sh
Last active Sep 1, 2019
Bash script to remove all revisions from github or gist repository.
View gitclean.sh
#!/bin/bash
#
# By Zibri (2019)
#
# Usage: gitclean username password giturl
#
gitclean ()
{
odir=$PWD;
if [ "$#" -ne 3 ]; then
@Zibri
Zibri / zibri_ssh.patch
Last active Sep 1, 2019
Patch for openssh adding option "-Z" so specify source port of connection of both ssh and scp)
View zibri_ssh.patch
diff -u openssh-7.6p1/scp.c openssh-7.6p1z/scp.c
--- openssh-7.6p1/scp.c 2017-10-02 21:34:26.000000000 +0200
+++ openssh-7.6p1z/scp.c 2019-08-31 19:06:33.708897414 +0200
@@ -152,6 +152,9 @@
/* This is the program to execute for the secured connection. ("ssh" or -S) */
char *ssh_program = _PATH_SSH_PROGRAM;
+/* This is used to store the source_port specified by -Z */
+char *source_port = NULL;
+
@Zibri
Zibri / browser_otp.js
Last active Aug 11, 2019
OTP NodeJS and pure Javascript one-liner
View browser_otp.js
// This code produces a different 6 digits OTP every 30 seconds.
// numDigits must be between 1 and 8
otp = await (async (secret,numDigits)=>(Array.prototype.reduce.call(new Uint8Array(await crypto.subtle.digest('SHA-512',new TextEncoder().encode(secret+(Math.floor(new Date().getTime()/30000)).toString(16)))), (a,b,c)=>((((a*257) ^ b) >>> 0) % (10**numDigits)) )).toString().padStart(numDigits,"0"))
("test_secret",6)
OR
Object.defineProperty(window, 'otp', { get: async (secret="test_secret",numDigits=6)=>(Array.prototype.reduce.call(new Uint8Array(await crypto.subtle.digest('SHA-512',new TextEncoder().encode(secret+(Math.floor(new Date().getTime()/30000)).toString(16)))), (a,b,c)=>((((a*257) ^ b) >>> 0) % (10**numDigits)) )).toString().padStart(numDigits,"0") });
@Zibri
Zibri / getusage.sh
Created Aug 5, 2019
Get network data usage from Android phone.
View getusage.sh
#!/bin/bash
# Get android network usage statistics from phone.
# by Zibri
function getUsage ()
{
rb=0;
tb=0;
for a in $(adb shell dumpsys netstats|grep "rb="|cut -d "=" -f 3|cut -d " " -f 1);
do
rb=$((rb+a/1024));
@Zibri
Zibri / reindent.sh
Created Aug 2, 2019
Reindent any bash script the "bash" way.
View reindent.sh
#!/bin/bash
# By Zibri (www.zibri.org)
# Usage: reindent script.sh >script_nicer.sh
#
reindent ()
{
rstr=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1);
source <(echo "Zibri () {";cat "$1"|sed -e "s/^\s\s\s\s/$rstr/"; echo "}");
echo '#!/bin/bash';
declare -f Zibri | head --lines=-1 | tail --lines=+3 | sed -e "s/^\s\s\s\s//;s/$rstr/ /"
View hex2bin_by_zibri.c
/*
Best hex2bin function I came up with.
By Zibri
Valid strings examples:
"1 d0 600d c0FFeE"
"01d0600dc0ffee"
Spaces are ignored.
Parsing stops at the first non hex character.
@Zibri
Zibri / background.js
Created Apr 23, 2019 — forked from danharper/background.js
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
View background.js
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@Zibri
Zibri / trick.txt
Last active Jul 26, 2019
A trick as old as Unix.
View trick.txt
$ echo ZWNobyAiQnllLWJ5ZSBXb3JsZCEiIDsjDSMhL2Jpbi9zaCAgICAgICAgICAgICAgICANCiMNZWNobyAiSGVsbG8gV29ybGQhIg0K | base64 -d >test.sh
$ chmod a+x test.sh
$ cat test.sh
#!/bin/sh
echo "Hello World!"
$ ./test.sh
Bye-bye World!
$
@Zibri
Zibri / eticheck.sh
Last active Jul 26, 2019
BASH script to know remaining credit in megabytes from etisalat data simcard
View eticheck.sh
#!/bin/bash
function eticheck ()
{
param=`curl --proxy "" -qsI "http://www.etisalat.eg/etisalat/notification/dashboard.html"|grep Location|cut -d "=" -f 2|tr -d "\r"`
eurl="http://www.etisalat.eg/dashboard/user/profile?dial=param:$param"
msisdn=`curl --proxy "" -qs -H 'DNT: 1' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.9,it;q=0.8' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36' -H 'Accept: application/json, text/plain, */*' -H 'Referer: http://www.etisalat.eg/etisalat/notification/dashboard.html' "http://www.etisalat.eg/dashboard/user/msisdn?dial=param:$param" --compressed|jq -r .msisdn`
data=`curl --proxy "" -qs -H 'DNT: 1' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.9,it;q=0.8' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36' -H 'Accept: application/json, text/plain, */*' -H 'Referer: http://w
You can’t perform that action at this time.