Skip to content

Instantly share code, notes, and snippets.

@wcypierre
wcypierre / .bashrc chroot fix
Last active December 20, 2015 08:09
[Chroot] .bashrc does not work
As the shell created when you chroot is a login shell, so .bashrc does not works.
Hence, cp the .bashrc to .bash_profile and it will work. Keep the .bashrc as well in the case that you need to spawn another bash instance
http://stackoverflow.com/questions/13570558/user-environment-is-not-sourced-with-chroot
@wcypierre
wcypierre / bin_lib_copy.sh
Created July 27, 2013 18:45
[Script] Copy Binary and dependencies(libraries) to a folder
#!/bin/bash
cp `which $1` /var/chroot/sshd/bin/;\
ldd `which $1`|awk '{print $3}'|grep -e '^/'|xargs -I{} cp -v --parent '{}' /var/chroot/sshd/
@wcypierre
wcypierre / ssh_chroot.txt
Created July 27, 2013 18:41
[HOWTO] SSH Chroot
http://www.debian.org/doc/manuals/securing-debian-howto/ap-chroot-ssh-env.en.html
http://stephan.paukner.cc/syslog/archives/332-SSH-daemon-in-a-chroot-on-Debian-lenny.html
http://www.gelato.unsw.edu.au/IA64wiki/DebianSSHChroot
@wcypierre
wcypierre / gist:6095072
Last active December 20, 2015 07:39
Copy binary with dependencies into a folder
cp /bin/sh /var/chroot/sshd/bin/;\
ldd /bin/sh|awk '{print $3}'|grep -e '^/'|xargs -I{} cp -v --parent '{}' /var/chroot/sshd/
Credits to: http://blog.jandorsman.com/2011/10/copying-a-binary-and-its-shared-libraries-to-a-chrooted-directory/
#!/usr/bin/php
<?php
// http://w3.tbd.my/thread-14121-post-163114.html#pid163114
//$key = "3"; // 3 = 51, "=" = 61
//echo "Original Algo: \n";
//var_dump(algo2($key));
@wcypierre
wcypierre / gist:5994996
Created July 14, 2013 17:19
[C/C++] Delete/Free exploitation
http://web.archive.org/web/20080703153358/http://taossa.com/index.php/2007/01/03/attacking-delete-and-delete-in-c
@wcypierre
wcypierre / gist:5990139
Created July 13, 2013 09:20
[C/C++] strcat.S: No such file or directory fix
strcat.S: No such file or directory
Its either you didn't include <string.h> or <cstring>, or the buffer size is too small so try to allocate the string into another string
@wcypierre
wcypierre / gist:5989871
Created July 13, 2013 07:49
[Posix UDP] What to consider when coding for the multithreaded udp server with thread pool
1. The socket's file descriptor must be global(if you wanted to share the socket)
2. You must pass the sizeof the destination length(sizeof(client_addr)) into the thread in pthread_create as if you do not then you won't get a correct result as the client_addr is a pointer to sockaddr_in instead of sockaddr_in, so the return value of sizeof() won't be the one that we wanted
@wcypierre
wcypierre / c_string empty
Last active December 19, 2015 17:09
[Howto] Empty a c-string
To empty the string(set strlen() to 0):
string[0] = '\0';
To empty the string till the first null character:
memset(string, 0, strlen(string));
To empty the string from the start till the end(for static array):
memset(string, 0, sizeof(string));
@wcypierre
wcypierre / VLC XVideo Adaptor Fix
Created June 28, 2013 18:32
[VLC]xcb_xv vout display error: no available XVideo adaptor - Patch
xcb_xv vout display error: no available XVideo adaptor
Set Video Output to X11 Video Output(XCB)