Skip to content

Instantly share code, notes, and snippets.

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 ..
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
View gist:49a80983aa96ee19052107fc94f8d6d0
#0 0x00007ff53fdda39b in recursive_DHT_bucket_get_nodes (bucket=0x16f57c0, nodes=0x0, number=number@entry=8,
public_key=public_key@entry=0x7ffd247512f0 "", friend_ok=friend_ok@entry=true, ret_ips=ret_ips@entry=true)
at ../toxcore/DHT.c:772
i = 7
counter = 0
#1 0x00007ff53fdda480 in recursive_DHT_bucket_get_nodes (bucket=bucket@entry=0x1a144d0, nodes=0x0,
number=number@entry=8, public_key=public_key@entry=0x7ffd247512f0 "", friend_ok=friend_ok@entry=true,
ret_ips=ret_ips@entry=true) at ../toxcore/DHT.c:746
ret = <optimized out>
#2 0x00007ff53fdda5c4 in dealloc_buckets (bucket=0x1a144d0) at ../toxcore/DHT.c:816
View thing.c
static void utox_group_peer_join_cb(Tox *tox, uint32_t groupnumber, uint32_t peer_id, void *UNUSED(user_data)) {
debug("newGC:\tpeer join group %u, peer %u\n", groupnumber, peer_id);
/* Get and store name for this group, used by other functions */
uint32_t name_length = tox_group_peer_get_name_size(tox, groupnumber, peer_id, NULL);
uint8_t *name = malloc(name_length + 1);
TOX_ERR_GROUP_PEER_QUERY err = 0;
tox_group_peer_get_name(tox, groupnumber, peer_id, name, &err);
if (err) {
debug("newGC:\tError getting peer %u name!\n", peer_id);
You can’t perform that action at this time.