Skip to content

Instantly share code, notes, and snippets.

@7castle
7castle / taskset.sh
Created November 5, 2015 21:58 — forked from ayufan/taskset.sh
KVM CPU pinning for Proxmox VE
#!/bin/bash
set -eo pipefail
VMID=200
cpu_tasks() {
expect <<EOF | sed -n 's/^.* CPU .*thread_id=\(.*\)$/\1/p' | tr -d '\r' || true
spawn qm monitor $VMID
expect ">"
@7castle
7castle / gist:5d38aeb5b545a43e6dbe
Created November 5, 2015 22:19
quorum fix all
Peetaur's Proxmox Quorum Magic 'Fix All'.
========================================
restarting these on the failed node, and the whole cluster might bring back quorum, fix corosync, and fix the red lights problem in the GUI. It's like rebooting without interrupting the VMs (reboot proxmox parts only).
To create this sequence, I used the order in /etc/rc2.d/, and then I tinkered until it worked:
Consider disabling HA first.
The procedure:
on all nodes, restart:
#!/usr/bin/perl -w
use constant {
TIMEZONE => 'Europe/Amsterdam'
};
use strict;
use PVE::API2Client;
use PVE::AccessControl;
use PVE::INotify;
@7castle
7castle / setuid-root-backdoor.md
Created November 6, 2015 00:17 — forked from dergachev/setuid-root-backdoor.md
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

@7castle
7castle / metasploit-links.md
Last active September 12, 2019 01:53 — forked from dergachev/metasploit-links.md
Metasploit links
@7castle
7castle / openvpn_minimal_install.sh
Last active September 12, 2019 01:52
openvpn minimal install
apt-get install openvpn
cp -R /usr/share/doc/openvpn/examples/easy-rsa/2.0/ /etc/openvpn/ca/
cd /etc/openvpn/ca/
. vars
. clean-all
. build-ca
. build-key-server server
. build-key client
. build-dh
vi /etc/openvpn/server.conf
@7castle
7castle / bashrc tweek
Last active September 12, 2019 01:50
bashrc tweek
export HISTCONTROL=ignoredups:erasedups
export HISTSIZE=100000
export HISTFILESIZE=100000
shopt -s histappend
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
@7castle
7castle / gist:3c658bef4c31069709f1e76dee138f88
Last active March 14, 2017 20:04 — forked from bsdlp/gist:5964937
owncloud nginx config
server {
listen 80;
server_name cloud.sjchen.net;
return 301 https://$server_name$request_uri; # enforce https
}
server {
server_name cloud.sjchen.net;
root /srv/owncloud;
@7castle
7castle / clients.md
Created March 14, 2017 20:07 — forked from defunkt/clients.md
A list of Gist clients.

Gist Clients

Want to create a Gist from your editor, the command line, or the Services menu? Here's how.

Editor Support

@7castle
7castle / install-ispconfig3-ubuntu.sh
Created March 24, 2017 19:20
Install ISPConfig3 Ubuntu 16.04 64Bits
#!/bin/bash
## Install ISPConfig3 on Ubuntu 16.04 64Bits
## Author: Nilton OS www.linuxpro.com.br
## https://www.howtoforge.com/tutorial/perfect-server-ubuntu-16.04-with-apache-php-myqsl-pureftpd-bind-postfix-doveot-and-ispconfig/
## Version 0.5
## Set lang en_US UTF8
## echo 'LC_ALL="en_US.utf8"' >>/etc/environment