Skip to content

Instantly share code, notes, and snippets.

View kevin39's full-sized avatar

Kevin LABECOT kevin39

View GitHub Profile
@kevin39
kevin39 / PfSense DNS Batch Creation
Last active September 20, 2016 12:25 — forked from brycied00d/gist:13483a1d8363e457f963
pfSense DNS Forwarder Batch Host Creation
<?php
// pfSense PHP script to generate a range of DNS forwarder hosts based on
// "dot${lastoctet}", eg. 192.0.2.100 == dot100.example.com
// Open terminal, run "php" copy/paste script with the following defines tweaked
// Ctrl-D, wait a moment until you see "Content-type: text/html"
// Open the DNS config in the web UI and click Apply Changes
define('DOT_DOMAIN', 'example.com');
define('DOT_SUBNET', '192.0.2.'); // Leave off the final octet, include the dot
define('DOT_RANGE_START', 100);
@kevin39
kevin39 / Ping reply on off using icmp_echo_ignore_all
Created September 21, 2016 08:39
Enable or Disable ping reply temporarily
Disable ping reply Temporarily
You can temporarily disable the ping reply using the following method.
# echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all
Please note that this setting will be erased after the reboot. To disable ping reply permanently (even after the reboot), follow the step mentioned below.
Also, to enable the ping reply back, set the value to “0” as shown below.
# echo "0" > /proc/sys/net/ipv4/icmp_echo_ignore_all
@kevin39
kevin39 / Identify a disk by its UUID
Last active September 21, 2016 09:28
DISK BY UUID
$ blkid /dev/sdg1
/dev/sdg1: LABEL="IPBXRECORDS" UUID="C4CD-C4FA" TYPE="exfat
$ ls /dev/disk/by-uuid -l
total 0
lrwxrwxrwx 1 root root 10 Jun 25 13:10 2d2fdee8-1307-4df4-b3d9-7e69c4e05bfc -> ../../sde1
lrwxrwxrwx 1 root root 10 Sep 21 05:18 2e21785b-b370-4e13-8449-6a5729ae3387 -> ../../dm-2
lrwxrwxrwx 1 root root 10 Jun 25 13:10 3655492c-fe05-4e5d-bd41-f9b85c86e884 -> ../../sdd1
lrwxrwxrwx 1 root root 10 Jun 25 13:11 36e9fd6f-bec6-4957-888c-c2d24b64f084 -> ../../sda1
lrwxrwxrwx 1 root root 10 Jun 25 13:10 5122218b-1688-4412-b6c5-e72e79c68180 -> ../../sdc1
@kevin39
kevin39 / DEBIAN_PACKAGE_SIGNATURE
Created September 20, 2016 12:22
Debian Package - "The following signatures couldn't be verified because the public key is not available"
gpg --keyserver pgp.mit.edu --recv-keys <LA_CLE>
gpg --armor --export <LA_CLE> | apt-key add -
@kevin39
kevin39 / spotify.ips.sh
Created September 23, 2016 06:38
Export Spotify servers IPs
#!/bin/sh
curl -A "http://bgp.he.net/search?search%5Bsearch%5D=spotify&commit=Search" -o /tmp/ips.raw "http://bgp.he.net/search?search%5Bsearch%5D=spotify&commit=Search"
grep -aoEw -e "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?/[0-9]{2})" -e "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" /tmp/ips.raw | sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n | uniq
@kevin39
kevin39 / Click2Call.php
Created September 23, 2016 06:42
Asterisk Click2Call using PHP
<?php
$from = $_GET[from];
$to = $_GET[to];
$fromext = $_GET[fromext];
$socket = fsockopen("localhost","5038", $errno, $errstr, $timeout);
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: USERNAME\r\n");
@kevin39
kevin39 / AsteriskAgentSummaryPerHour.sql
Last active September 23, 2016 06:49
Asterisk - Agent outgoing call summary per hour
SELECT Heure, ROUND(AVG(nbAppels),2) nbAppelsMoyen
FROM
(
SELECT DATE_PART('day',eventtime) Jour, DATE_PART('hour',eventtime) Heure, count(DISTINCT cid_name) nbAppels
FROM cel
WHERE eventtime >= '2016-02-01 00:00:00'
AND eventtime < '2016-03-01 00:00:00'
AND eventtype = 'CHAN_START'
AND context = 'from-extern'
GROUP BY DATE_PART('day',eventtime), DATE_PART('hour',eventtime)
@kevin39
kevin39 / Click2Spy.php
Last active September 23, 2016 06:49
Asterisk - Click2Spy One click to spy an agent using a PHP script
<?php
$from = $_GET[from];
$to = $_GET[to];
$socket = fsockopen("localhost","5038", $errno, $errstr, $timeout);
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: USERNAME\r\n");
fputs($socket, "Secret: PASSWORD\r\n\r\n");
$wrets=fgets($socket,128);
@kevin39
kevin39 / kill using pkill
Created September 27, 2016 12:46
Kill processed by argument
$ sleep 30& sleep 60&
[1] 8007
[2] 8008
$ pkill -f 'sleep 30'
[1] - terminated sleep 30
$ pgrep sleep
8008
@kevin39
kevin39 / Setup a restricted shell
Last active October 10, 2016 14:31
Restricted bash shell
Source : http://www.tecmint.com/rbash-a-restricted-bash-shell-explained-with-practical-examples/
# cd /bin
# ln -s bash rbash
Extra setup to improve security :
http://blog.bodhizazen.net/linux/how-to-restrict-access-with-rbash/