Skip to content

Instantly share code, notes, and snippets.

View aalfiann's full-sized avatar
🏠
Working from home

M ABD AZIZ ALFIAN aalfiann

🏠
Working from home
View GitHub Profile
@aalfiann
aalfiann / proxy_curl.php
Created November 25, 2017 04:47 — forked from mlconnor/proxy_curl.php
PHP CURL Code to grab a file through a proxy
<?php
print get_file('http://www.google.com');
function get_file($url) {
$curl = curl_init();
$options = default_ops(array(CURLOPT_URL => $url));
curl_setopt_array($curl, $options);
$output = curl_exec($curl);
@aalfiann
aalfiann / gist:c0cbb90b8cbdd7845da0359245bdbdb1
Created February 1, 2018 12:13 — forked from yonjah/gist:5082855
Blocking DDOS bots with JavaScript for fun and profit! Or how easy it is to break the current protection methods and how to make it better.
TL;DR - jump to the challenge at the end
====ON BLOCKING EVIL BOTS=====
On a resent job interview I had for "Incapsula" a few days ago I was put to the challenge to break
their bot protection mechanism. Apparently node.js is not that common among bot writes and most bots
are not able to run javascript.
The challenge had two parts -
1. find what the code does.
2. implement a bot that will break the code without using js.
3. think how to make this code unbreakable
@aalfiann
aalfiann / .gitignore
Created February 13, 2018 08:42 — forked from SaltwaterC/.gitignore
php cache curl
/cache/
@aalfiann
aalfiann / download-unzip.php
Created May 14, 2018 06:06 — forked from philipp-r/download-unzip.php
Download and unzip file with PHP
<?php
// get latest german WordPress file
$ch = curl_init();
$source = "https://de.wordpress.org/latest-de_DE.zip"; // THE FILE URL
curl_setopt($ch, CURLOPT_URL, $source);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec ($ch);
curl_close ($ch);
@aalfiann
aalfiann / ajenti-v-php7.sh
Last active September 13, 2018 07:43 — forked from kn9/ajenti-v-php7.sh
Ubuntu 14.04 Nginx Web Server with Ajenti with PHP 7.0
#Set Hostname
nano /etc/hostname
nano /etc/hosts
#set Timezone
dpkg-reconfigure tzdata
#reboot to refresh the hostname
reboot
<?php
$url = 'url';
$proxyauth = 'user:pass';
$proxy = 'proxy.server.es';
$proxyPort = '8080';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
//proxy suport
@aalfiann
aalfiann / gist:a600a2f629b26b4196fc5eb7379df0d6
Created July 17, 2019 11:29 — forked from klovadis/gist:2549131
How to use optional arguments in node.js
// example function where arguments 2 and 3 are optional
function example( err, optionalA, optionalB, callback ) {
// retrieve arguments as array
var args = [];
for (var i = 0; i < arguments.length; i++) {
args.push(arguments[i]);
}
// first argument is the error object
@aalfiann
aalfiann / postman_install.sh
Created August 1, 2019 04:38 — forked from cagcak/postman_install.sh
Postman install Ubuntu 18.04
#!/bin/bash
# Get postman app
wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz
sudo tar -xzf postman.tar.gz -C /opt
sudo ln -s /opt/Postman/Postman /usr/bin/postman
#Create a Desktop Entry
cat > ~/.local/share/applications/postman.desktop <<EOL
[Desktop Entry]
Encoding=UTF-8
@aalfiann
aalfiann / client.js
Created August 6, 2019 11:59 — forked from PaulMougel/client.js
File upload in Node.js to an Express server, using streams
// node: v0.10.21
// request: 2.27.0
var request = require('request');
var fs = require('fs');
var r = request.post("http://server.com:3000/");
// See http://nodejs.org/api/stream.html#stream_new_stream_readable_options
// for more information about the highWaterMark
// Basically, this will make the stream emit smaller chunks of data (ie. more precise upload state)
var upload = fs.createReadStream('f.jpg', { highWaterMark: 500 });
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
DISTRO=
OS=
if grep 'Debian' /etc/issue > /dev/null 2>&1 ; then