Skip to content

Instantly share code, notes, and snippets.

@nuit
nuit / rotall.py
Created December 17, 2015 03:21
Cifra de Cesar - cifrar <-> quebrar
import sys
a=list('abcdefghijklmnopqrstuvwxyz')
A=list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
s=raw_input('texto: ')
def rot(k):
for j in s:
if j==' ':
sys.stdout.write(' ')
if j.isupper():
@nuit
nuit / proxy.py
Last active August 29, 2015 14:24
Simple web proxy in Python.
import socket, sys, thread, re
import httplib, urllib2
global ip_client
ip_client=urllib2.urlopen('https://enabledns.com/ip')
ip_client=ip_client.read()
def start():
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@nuit
nuit / authserver.py
Last active August 29, 2015 14:22
Python TGS - Kerberos Simulation
import socket
import sys
from thread import *
import sqlite3
from Crypto.Cipher import DES
from Crypto import Random
HOST = ''
PORT = 8888
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@nuit
nuit / vernam.c
Created April 10, 2015 16:10
vernam
#include <stdio.h>
int main(){
int M,m;
int ch,k,r;
ch=getchar();
//ascii >> A=65,a=97 e Z=90,z=122
for (M=65, m=97;(M<=90) && (m<=122);M++, m++){
while ((ch=getchar()) != EOF){
r=rand()%26;
@nuit
nuit / wargame example
Created September 12, 2014 04:55
wargame.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int
main(int argc, char **argv)
{
char password[] = "zeldani";
if(argc < 2)
@nuit
nuit / bmatrix.py
Created August 21, 2014 02:38
basic matrix operations with numpy
import numpy as np
x=np.array([1,5,2])
y=np.array([7,4,1])
z=np.array([[1,2,3],
[4,5,6],
[7,8,9]])
a=x+y
m=x*y
t=z.transpose()
print a,m,'\n',t
@nuit
nuit / matrix.py
Last active August 29, 2015 14:05
inverse matrix encryption
import string
import numpy as np
from numpy.linalg import inv
M = [[7,18,5],
[1,20,23],
[15,18,11]]
C = np.array([[1,1,2],
[1,2,2],
[1,4,3]])
@nuit
nuit / histogram.py
Last active August 29, 2015 14:05
scidavis, python, histogram
import numpy as np
import pylab as pl
dados = np.random.normal(5.0, 3.0, 1000)
pl.hist(dados)
pl.xlabel('dados')
pl.title('Meu Histograma')
pl.show()
@nuit
nuit / linearfit.py
Last active August 29, 2015 14:05
scidavis linear fit, leasts squares model
import numpy as np
import pylab as pl
x1 = np.arange(15)
y1 = 0.5*x1 + 0.6
x2=[0,2,4,6,8,10,12,14]
y2=[0,2,4,4,5,5,7,8]
plot1=pl.plot(x1,y1,'r')
plot2=pl.plot(x2,y2,'go')
@nuit
nuit / nmapp.py
Created July 26, 2014 14:27
Nmap fun
import nmap
import optparse
def nmapScan(tgtHost, tgtPort):
nmScan = nmap.PortScanner()
nmScan.scan(tgtHost, tgtPort)
state=nmScan[tgtHost]['tcp'][int(tgtPort)]['state']
print " [*] " + tgtHost + " tcp/"+tgtPort+" "+state
def main():
parser = optparse.OptionParser('usage%prog' +