Exemplo n.º 1
0
def test_scheduler_times():
    """
    test wait_times in sum are less than max time
    """
    for _ in itertools.repeat(None, 1000):
        max_time = 100
        wait_times = gen_schedule_wait_times(max_time)
        time_sum = sum(map(float, wait_times))
        # print(wait_times)
        assert (time_sum < max_time)
Exemplo n.º 2
0
warmup_time = int(sys.argv[1])
recording_time = int(sys.argv[2])
is_exploit = int(sys.argv[3])
do_exploit = True
if is_exploit < 1:
    do_exploit = False

total_duration = warmup_time + recording_time
exploit_time = random.randint(int(recording_time * .3), int(recording_time * .8))

min_user_count = 10
max_user_count = 25
user_count = random.randint(min_user_count, max_user_count)

wait_times = [gen_schedule_wait_times(total_duration) for _ in range(user_count)]


class CVE_2012_2122(Scenario):
    def init_victim(self, container, logger):
        port = get_host_port(container, "3306")
        try:
            db = pymysql.connect("localhost", "root", "123456", port=port)
            try:
                db.cursor().execute('create database ' + "textDB")
            except:
                pass

            self.db = pymysql.connect("localhost", "root", "123456", "textDB", port)
            sql = """CREATE TABLE `texts` (
                         `id` int(11) NOT NULL AUTO_INCREMENT, 
Exemplo n.º 3
0
 def __init__(self, actions, total_duration):
     self.scheduler = sched.scheduler(time.time, time.sleep)
     self.actions = actions
     self.wait_times = gen_schedule_wait_times(total_duration)
Exemplo n.º 4
0
 def generate_wait_times(self, user_count, duration):
     wait_times: List[List[float]] = []
     for _ in range(user_count):
         wait_times.append(gen_schedule_wait_times(duration))
     return wait_times