Skip to content

Instantly share code, notes, and snippets.

@1stvamp
1stvamp / mac-curl-ca-bundle.sh
Created March 22, 2012 12:50
Script to install cURL CA certificates on OS X without macports
#!/bin/bash
mkdir /tmp/curl-ca-bundle
cd /tmp/curl-ca-bundle
wget http://curl.haxx.se/download/curl-7.22.0.tar.bz2
tar xzf curl-7.22.0.tar.bz2
cd curl-7.22.0/lib/
./mk-ca-bundle.pl
if [ ! -d /usr/share/curl/ ]; then
sudo mkdir -p /usr/share/curl/
else
@cballou
cballou / get-ip-address-optimized.php
Created March 26, 2012 00:51
PHP - Advanced Method to Retrieve Client IP Address
<?php
function get_ip_address() {
$ip_keys = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR');
foreach ($ip_keys as $key) {
if (array_key_exists($key, $_SERVER) === true) {
foreach (explode(',', $_SERVER[$key]) as $ip) {
// trim for safety measures
$ip = trim($ip);
// attempt to validate IP
if (validate_ip($ip)) {
# Copied from http://ttaportal.org/wp-content/uploads/2012/10/7-Reallocation-using-LVM.pdf
##
## Showing the problem: need to reallocate 32GB from /dev/mapper/pve-data to /dev/mapper/pve-root
##
df -h
# Filesystem Size Used Avail Use% Mounted on
# /dev/mapper/pve-root 37G 37G 0 100% /
# tmpfs 2.0G 0 2.0G 0% /lib/init/rw
@KyleGawryluk
KyleGawryluk / gist:7418600
Created November 11, 2013 19:09
SugarCRM - Generating custom error popup from logic hook
Create a custom view to load popup widget js
custom/modules/{module}/views/view.detail.php
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('include/json_config.php');
require_once('include/MVC/View/views/view.detail.php');
class po_purchaseOrdersViewDetail extends ViewDetail {
@dergachev
dergachev / setuid-root-backdoor.md
Last active March 16, 2024 00:49
How to use setuid to install a root backdoor.

Why You Can't Un-Root a Compromised Machine

Let's say somebody temporarily got root access to your system, whether because you "temporarily" gave them sudo rights, they guessed your password, or any other way. Even if you can disable their original method of accessing root, there's an infinite number of dirty tricks they can use to easily get it back in the future.

While the obvious tricks are easy to spot, like adding an entry to /root/.ssh/authorized_keys, or creating a new user, potentially via running malware, or via a cron job. I recently came across a rather subtle one that doesn't require changing any code, but instead exploits a standard feature of Linux user permissions system called setuid to subtly allow them to execute a root shell from any user account from the system (including www-data, which you might not even know if compromised).

If the "setuid bit" (or flag, or permission mode) is set for executable, the operating system will run not as the cur

@hwdsl2
hwdsl2 / README.md
Last active March 17, 2023 00:57
My IPTables rules for securing the Asterisk VoIP server
@lrstanley
lrstanley / tunnel_4to6.py
Last active July 12, 2023 22:27
How to use tunnelbroker tunnels on KVM/OpenVZ/etc. (Debian)
"""
HE-2-4 Copyright (C) 2014 Liam Stanley
License: Eiffel Forum License, version 2
- https://links.ml/FFa1
Website: https://liamstanley.io
NOTE: THIS IS FOR KVM BASED SERVERS ONLY.
I'M NOT ADDING CUSTOM CHECKS TO SEE IF
YOU'RE USING KVM.
"""
@binarytemple
binarytemple / sourceforge.to.github.impor.markdown
Created April 27, 2015 09:05
import a sourceforge project (with full history) to github

In order to clone the TVN application from sourceforge to github I performed the following steps.

rsync -av rsync://tnv.cvs.sourceforge.net/cvsroot/tnv/* .
svn export --username=guest http://cvs2svn.tigris.org/svn/cvs2svn/trunk cvs2svn-trunk
cp ./cvs2svn-trunk/cvs2git-example.options ./cvs2git.options
vim cvs2git.options
cvs2svn-trunk/cvs2git --options=cvs2git.options --fallback-encoding utf-8
git@github.com:binarytemple/tnv.git tnv-github
git clone git@github.com:binarytemple/tnv.git tnv-github
STEP #1 – change your company logo (let’s start from easy…)
Hover the big Odoo logo on the left side, click on “Edit company data” and give your company your own logo – this will replace the Odoo placeholder logo.
STEP#2 – remove “Powered by Odoo”
Open the view web.login_layout and comment out following lines:
<!-- <span class="oe_footer_seperator"> | </span> -->
<!-- <a href="https://www.odoo.com" target="_blank">Powered by <span>Odoo</span></a> -->
Open the view web.menu_secondary and comment out following line:
anonymous
anonymous / gist:8b4a0101f5101f756bb9
Created July 2, 2015 11:26
Get OAUTH2.0 access token for Google Voice with a shell-script
#!/bin/bash
##
## Authenticate with Google Voice
##
USAGE="`basename $0` {auth|refresh|token} ctx"
CTX_DIR=$HOME/.gvauth
CLIENT_ID="YOUR_CLIENTID_FROM_GOOGLE_DEVELOPER_CONSOLE"
CLIENT_SECRET="YOUR_CLIENTSECRET_FROM_GOOGLE_DEVELOPER_CONSOLE"
SCOPE="https://www.googleapis.com/auth/googletalk%20https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/userinfo.profile"