Skip to content

Instantly share code, notes, and snippets.

@mmkhitaryan
mmkhitaryan / README.md
Created September 1, 2024 20:40
AWS ECS stuck in PENDING state g4dn

Disk space issue

In my case I used container which had size of 12GB. It contained yolo model for inference, so the container was large. By default the size of template for ECS ec2 is 30GB, so it could not conain entire OS+Image.

The solution was changing the template root storage to 100GB.

Card type issue

Another case of PROVISIONING stuck was with spot instances. I wanted to save on inference costs, so wanted to run spot instead of on-Demand.

I set the filter to GPU accelerator, and selected all the instances which had GPU. The issue was that there are also non-ndidia GPUs in AWS. So Nvidia driver linux got installed on AMD machines, and the tasks got stuck in PROVISIONING state.

import datetime
from tortoise import Tortoise, fields, timezone
from tortoise.models import Model
NAIVE_DATETIME = datetime.datetime.strptime("2024-2-11","%Y-%m-%d")
class TortoiseModel(Model):
name = fields.CharField(max_length=50, unique=True)
last_register_date = fields.DatetimeField()
@mmkhitaryan
mmkhitaryan / subdomain_finder.js
Created January 6, 2024 17:57
I wanted to find free 2 character netlify subdomain name, but found no :(
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function generateRandomString() {
const randomChar1 = String.fromCharCode(Math.floor(Math.random() * 26) + 65); // Random uppercase letter
const randomChar2 = String.fromCharCode(Math.floor(Math.random() * 26) + 65); // Another random uppercase letter
// Concatenate the two characters
const randomString = randomChar1 + randomChar2;
from collections import defaultdict
pid_to_command_line = {}
list_of_all_processes = []
import csv
field_names = None
import r2pipe
r = r2pipe.open()
r.cmd('ood')
r.cmd('dcu @main')
last_pointer = '1'
while True:
poiner_from_stack = str(r.cmdj('pxqj 8 @rsp')[0])
@mmkhitaryan
mmkhitaryan / run_in_r2.py
Last active September 11, 2022 21:26
Bug in r2pipe?
# r2 /bin/ls
# . ./run_in_r2.py
# 1
# 2
# ... 1000+
import r2pipe
r = r2pipe.open()
# python stack_seeker.py some_file_in_cwd
import r2pipe
import sys
r = r2pipe.open('/bin/ls')
r.cmd('ood')
r.cmd('aaa')
file_name = sys.argv[1]
@mmkhitaryan
mmkhitaryan / hello.c
Created August 30, 2022 10:13
In original article you need to specify the function address manually. I made it detect the function address automatically.
#include <stdio.h>
#include <unistd.h>
void
f (int n)
{
printf ("Number: %d\n", n);
}
int

My router has been crashing when my PC boots, and starts working good after 5 minutes of restart. So I decided to dig into reasons of the crash.

I used tcpdump and made it start on system boot. It collected all the packets, and then used tcpdump replay to try to reproduce the crashes.

When I replayed all the packets, the router crashed as suspected. But I needed to understand what specific packets were the reason of the crashing.

So I started cutting the file in half, (basically binary search) and seeing if the crash happens on. I ended up with ~20 packets, and then choose those packets that are on the scapy script.

I wanted to continue the research of the reasons of the vulnerability, emulate the router firmware and try to crash it. But I did not find router's working firmware anywhere.

@mmkhitaryan
mmkhitaryan / deadlock.py
Created July 4, 2021 19:35
An example of python deadlock
from threading import Lock, Thread
accountone = Lock()
accounttwo = Lock()
def transfer(accountone, accounttwo):
accountone.acquire()
accounttwo.acquire()
print("Transaction done")
accountone.release()