Skip to content

Instantly share code, notes, and snippets.

View deepal's full-sized avatar

Deepal Jayasekara deepal

  • CompareTheMarket.com
  • London, United Kingdom
View GitHub Profile
def startClient():
from ftplib import FTP
thread.start_new_thread(validation_server, (TCP_CON_PORT,))
hostname = sys.argv[2]
ftp = FTP(hostname)
ftp.login()
filepath = sys.argv[3]
encFilepath = encrypt(filepath)
localfile = open(encFilepath,"rb")
def startServer():
authorizer = DummyAuthorizer()
authorizer.add_anonymous(USER_HOME + "/anonymous", perm='elradfmwM')
handler = MyHandler
handler.authorizer = authorizer
handler.banner = "Server Ready.."
hostname = ""
address = (hostname,21)
server = FTPServer(address, handler)
def encrypt(filepath):
print "[!] Starting Encryption...."
aes_key = os.urandom(32)
out_filename = filepath + ".enc"
filehash = hashlib.md5(open(filepath).read()).hexdigest()
public_key_loc = PUB_KEY_LOC
pubkey = open(public_key_loc, "r").read()
rsakey = RSA.importKey(pubkey)
def decrypt(filepath):
print "[!] Starting decryption...."
dec_filename = ANONYMOUS_FILEPATH + os.path.basename(filepath).strip(".enc")
inFile = open(filepath,"r")
chunksize=64*1024
hash = inFile.read(32)
encAESKey = inFile.read(512)
private_key_loc = PRIV_KEY_LOC
privkey = open(private_key_loc, "r").read()
def validateIntegrity(orighash, destfilepath):
desthash = hashlib.md5(open(destfilepath, "rb").read()).hexdigest()
if(orighash==desthash):
send_validation_result("1")
return True
else:
os.system("rm "+destfilepath)
send_validation_result("0")
return False
#!/usr/bin/env python
import os, random, sys, hashlib, struct, thread, socket
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
from Crypto.Cipher import AES
from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_OAEP
#! /usr/bin/python2
import utils, hashlib, time, random
from math import ceil
class ElGamalSignature(object):
def __init__(self, p = None, x = None, g = None):
if p == None and x == None:
eval("var number1 = 100");
var number2 = 200;
var number3 = number1 + number2;
console.log(number3)
@deepal
deepal / nodesec-eval.sh
Created February 16, 2016 17:43
nodesec-eval
> mystr
ReferenceError: mystr is not defined
at repl:1:1
at REPLServer.defaultEval (repl.js:252:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:417:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:210:10)
@deepal
deepal / nodesec-csrf-express.js
Last active October 14, 2019 20:58
nodesec-csrf-express
var csrf = require('csurf');
/*some code here*/
var app = express();
/*some code here*/
app.use(csrf());
app.get('/', function(req, res, next){
res.render('index', {
_csrfToken = req.csrfToken();
});