Skip to content

Instantly share code, notes, and snippets.

View bararchy's full-sized avatar

Bar Hofesh bararchy

View GitHub Profile
@bararchy
bararchy / ssh.c
Created November 25, 2014 14:07
C SSH
#include <libssh/libssh.h>
#include <libssh/server.h>
#include <libssh/callbacks.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
/* some def */
int main ()
@bararchy
bararchy / loop.c
Created November 27, 2014 10:13
C and ruby
int authenticate(ssh_session session) {
ssh_message message;
do {
message=ssh_message_get(session);
if(!message)
break;
switch(ssh_message_type(message)){
case SSH_REQUEST_AUTH:
switch(ssh_message_subtype(message)){
case SSH_AUTH_METHOD_PASSWORD:
@bararchy
bararchy / IRC_RCA.rb
Created December 2, 2014 14:18
Try 5
require 'securerandom'
require 'thread'
require 'prime'
require 'openssl'
require 'socket'
require 'zlib'
require 'base64'
class IRC_RSA
@bararchy
bararchy / tester.rb
Last active August 29, 2015 14:18
Testing Gsub
require 'benchmark/ips'
file = File.read("/home/unshadow/Desktop/text.txt")
data = file
Benchmark.ips do |bench|
bench.config(time: 5, warmup: 2)
bench.report("#gsub") do
unused = file.gsub(/Setting up/,'o')
file = data
def self.read_for_tcp_proxy(socket)
data = socket.read_nonblock(16_384)
while socket.pending > 0
data += socket.read_nonblock(16_384)
end
data
rescue IO::WaitReadable
@bararchy
bararchy / LibInject.rb
Last active August 29, 2015 14:20
Libinjection Ruby Wrapper
module LibInject
extend FFI::Library
ffi_lib_flags :now, :global
ffi_lib 'libinjection.so'
class Sfilter < FFI::Struct
# layout :s, :pointer,
# :slen, :size_t,
# :userdata, :pointer,
# :flags, :int,
# :pos, :size_t
@bararchy
bararchy / rproxy.rb
Last active August 29, 2015 14:20 — forked from buzztaiki/rproxy.rb
# HTTP Reverse proxy server
# Original Source: http://rubyforge.org/snippet/download.php?type=snippet&id=162
# Use case: you have several services running as different users
# for security purposes (they might even be chrooted).
# In production we use apache but for testing I prefer to use
# webrick because I find it more flexible for unit testing.
# The proxy mapping is modelled on the ProxyPass directive
# of apache. For example:
#
def self.rewrite_content_length(data)
new_size = data[:http_body].bytesize
if data[:http_headers].match(/Content-Length: (.*?)\r?\n/i)
data[:http_headers].gsub!(/Content-Length: (.*?)\r?\n/i, "Content-Length: #{new_size}\n")
else
data[:http_headers].strip!
data[:http_headers] << "\nContent-Length: #{new_size}\n\n"
end
data
end
## Former code which works:
Thread.new(server.accept) do |client|
if client
addr = client.peeraddr if client
log.info("Client connected from IP: #{addr.ip_address} and port: #{addr.ip_port}") if log && addr
package_parser(client, log)
client.close if client
end
end
# Maintainer: Jonne Haß <me@jhass.eu>
# Contributor: Mikkel Kroman <mk@maero.dk>
pkgname=crystal-git
pkgver=0.7.4.r0.g42efdbf
_last_release="0.7.4-1"
pkgrel=1
pkgdesc="The Crystal Programming Language"
arch=('i686' 'x86_64')
url="http://crystal-lang.org"