Skip to content

Instantly share code, notes, and snippets.

@Kirill89
Kirill89 / memory_layout.md
Created January 30, 2018 15:14 — forked from CMCDragonkai/memory_layout.md
Linux: Understanding the Memory Layout of Linux Executables

Understanding the Memory Layout of Linux Executables

Required tools for playing around with memory:

  • hexdump
  • objdump
  • readelf
  • xxd
  • gcore
@Kirill89
Kirill89 / test.js
Last active January 11, 2018 09:03
Escape MySQL LIKE % and _ characters in JavaScript
// https://dev.mysql.com/doc/refman/5.7/en/string-comparison-functions.html#operator_like
const escapeLike = str => str.replace(/\\/g, '\\\\').replace(/([%_])/g, '\\$1');
console.log(escapeLike('%test_') === '\\%test\\_');
console.log(escapeLike('\\%test\\_') === '\\\\\\%test\\\\\\_');
console.log(escapeLike('\\\\%test\\\\_') === '\\\\\\\\\\%test\\\\\\\\\\_');
abstract class SocialAuth
{
protected $id, $key, $url, $token, $userId, $service;
public function setParams($id, $key, $url)
{
$this->id = $id;
$this->key = $key;
$this->url = $url;
}
@Kirill89
Kirill89 / AES-128
Created September 12, 2012 14:17
AES-128
var str = "qwertyuio";
byte[] key = new byte[]{0,134,84,0,67,0,0,53,0,0,125,0,23,0,0,33};//Encoding.ASCII.GetBytes("1234567890123456");
var res = RpcClient.EncryptBytesAes(str, key, new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0});
Console.WriteLine(BitConverter.ToString(res));
Console.WriteLine(RpcClient.DecryptBytesAes(res, key, new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));
public static byte[] EncryptBytesAes(string input, byte[] key, byte[] initialVector)
{
byte[] encrypted;
using (AesManaged aesAlg = new AesManaged())