Skip to content

Instantly share code, notes, and snippets.

View gist:1857dcebb7e5afec11697c1fe47f3966
2924466F229DFE84E8E582781467CBFB924A9A056426CEE5186AF5F0BB7B95060A55A1D5CCB8
View illegal_arrays.py
#!/usr/bin/env python3
from sys import argv
"""
Converts a string representation of a sorted array of integers `s` into a bitfield.
e.g. indicesToBin("1 2 4 9 10 13 15 17 18 20 21 25 26 28 29 33 34 36 37 38 39")
-> "01101000011001010110110001101100011011110"
View gist:d001756561ba717a57b08238396b5573
1. Peer A receives Peer B's announcement from DHT:
A -> B send handshake request GH_REQUEST & HS_INVITE_REQUEST
B -> A send handshake response GH_RESPONSE & HS_INVITE_REQUEST
A -> B send invite request GP_INVITE_REQUEST
B -> A send invite response GP_INVITE_RESPONSE
A -> B send sync request GP_SYNC_REQUEST
B -> A send sync response GP_SYNC_RESPONSE
B -> A send all other peer announcements [goto: 2]
A -> Connection State = CS_CONNECTED
View gist:8b44be4795b906c4fdbe08695364dbde
==31062==ERROR: AddressSanitizer: heap-use-after-free on address 0x7f997d2ae458 at pc 0x7f99968ffd1a bp 0x7fff469dafa0 sp 0x7fff469da748
WRITE of size 40 at 0x7f997d2ae458 thread T0
#0 0x7f99968ffd19 (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x5ed19)
#1 0x7f999665f67a in clear_array_entry (/usr/local/lib/libtoxcore.so.2+0x5567a)
View gist:dcfae0ea6a6976547dcb80abeff3f924
c-toxcore:
install dependencies listed here: https://github.com/TokTok/c-toxcore/blob/master/INSTALL.md#requirements
git clone https://github.com/toktok/c-toxcore
cd c-toxcore
git checkout -b ngc
git pull origin ngc
mkdir _build && cd _build
cmake -DUSE_TEST_NETWORK=ON ..
cmake --build . && sudo make install
View gist:0ba18db7ec2d8411c79548423fbbb85e
{
"auto_complete": false,
"auto_indent": true,
"auto_match_enabled": false,
"color_scheme": "Packages/Materialize/schemes/Material Oceanic Next.tmTheme",
"font_size": 9,
"ignored_packages":
[
"Vintage"
],
View comparison.c
/* Basic rust callback function */
pub fn func(data: &[u8], src_addr: &SocketAddr, obj: &Rc<RefCell<Any>>) {
let mut temp = obj.borrow_mut();
let mut dht = match temp.downcast_mut::<DHT>() {
Some(dht) => dht,
None => return,
};
...
View sdfsd.rs
let port = match get_available_port(DEAFULT_PORT_FROM, DEFAULT_PORT_TO) {
Some(port) => port,
None => panic!("failed to find available port"),
};
let sockaddr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), port);
let new_sock = match UdpSocket::bind(&sockaddr) {
Ok(sock) => sock,
Err(e) => panic!("failed to bind socket to port {}; err={:?}", port, e),
View sdfsd.rs
/**
* Converts a string representation of a key into a byte array. The supplied
* string must contain 64 hex-characters.
*
* Returns a byte array of length 32 on success.
* Returns None on failure.
*/
pub fn key_string_to_bytes(s: &str) -> Option<[u8; 32]> {
if s.len() < 64 {
return None;
View evil.py
#!/usr/bin/python
key = 'kw6PZq3Zd;ekR[_1'
ret = ''
for i, ch in enumerate(key):
ecx = i + 1
edx = 0x66666667
eax = ecx
eax = edx * eax