コード例 #1
0
ファイル: bhp_fuzzer.py プロジェクト: C1tas/BlackHatPython
    def mutate_payload(self, original_payload):
        # pick a simple mutator or even call an external script
        picker = random.randint(1, 3)

        # select a random offset in the payload to mutate
        offset = random.randint(0, len(original_payload)-1)
        payload = original_payload[:offset]

        # at the random offset insert a SQL injection attempt
        if picker == 1:
            payload += "'"

        # jam an XSS attempt in
        if picker == 2:
            payload += "<script>alert('BHP!');</script>"

        # repeast a chunk of the original payload a random number
        if picker == 3:
            chunk_length = random.randint(len(payload[offset:]), len(payload)-1)
            repeater = random.randin(1, 10)

            for i in range(repeater):
                payload += original_payload[offset:offset + chunk_length]

        # add the remaining bits of the payload
        payload += original_payload[offset:]

        return payload
コード例 #2
0
    def mutate_payload(self, original_payload):
        # pick a simple mutator or even call an external script
        picker = random.randint(1, 3)

        # select a random offset in the payload to mutate
        offset = random.randint(0, len(original_payload) - 1)
        payload = original_payload[:offset]

        # at the random offset insert a SQL injection attempt
        if picker == 1:
            payload += "'"

        # jam an XSS attempt in
        if picker == 2:
            payload += "<script>alert('BHP!');</script>"

        # repeast a chunk of the original payload a random number
        if picker == 3:
            chunk_length = random.randint(len(payload[offset:]),
                                          len(payload) - 1)
            repeater = random.randin(1, 10)

            for i in range(repeater):
                payload += original_payload[offset:offset + chunk_length]

        # add the remaining bits of the payload
        payload += original_payload[offset:]

        return payload
コード例 #3
0
 def contort_Payload(self, original_payload):
     picker = random.randint(1, 3)
     offset = random.randint(0, len(original_payload)-1)
     payload = original_payload[:offset]
     if picker == 1:
         payload += "'"
     if picker == 2:
         payload += "<script>alert('BHP!');</script>"
     if picker == 3:
         chunk_length = random.randint(len(payload[offset:]), len(payload)-1)
         repeater = random.randin(1, 10)
         for i in range(repeater):
             payload += original_payload[offset:offset + chunk_length]
     payload += original_payload[offset:]
     return payload
コード例 #4
0
    def sample_behaviour(self, batch_size):
        states = []
        actions = []

        for index, pair in enumerate(zip(self.states, self.actions)):
            state, action = pair

            if index < batch_size:
                states.append(state)
                actions.append(action)
            else:
                selected_index = random.randin(0, index)
                if selected_index < batch_size:
                    states[selected_index] = state
                    actions[selected_index] = action

        return np.array(states), np.array(actions)
コード例 #5
0
ファイル: baseClass.py プロジェクト: celowe/Entities
    def saving_throw(self):
        # Fortitude
        roll = random.randint(1, 20)
        fortRoll = (roll + Fort)
        print("Roll", roll)
        if roll == 1:
            print("Save misses")

        elif fortRoll <= 19:
            # check if it saves
            print("Succesfully saved!")

        elif roll == 20:
            print("Succesfully saved!")

        # Reflex
        roll = random.randint(1, 20)
        reflexRoll = (roll + Reflex)
        print("Roll", roll)
        if roll == 1:
            print("Save misses")

        elif relfexRoll <= 19:
            # check if it saves
            print("Succesfully saved!")

        elif roll == 20:
            print("Succesfully saved!")

        # Will
        roll = random.randin(1, 20)
        willRoll = (roll + Will)
        print("Roll", roll)
        if roll == 1:
            print("Save misses")

        elif willRoll <= 19:
            # check if it saves
            print("Succesfully saved!")

        elif roll == 20:
            print("Succesfully saved!")
コード例 #6
0
def get_pearl_type(item):
    rand = random.randint(1, 100)
    if rand <= 25:
        item['name'] = item['name'] + " (1st lvl)"
    elif rand <= 45:
        item['name'] = item['name'] + " (2nd lvl)"
        item['gplo'] = int(item['gplo']) * 2
        item['xplo'] = int(item['xplo']) * 2
    elif rand <= 60:
        item['name'] = item['name'] + " (3rd lvl)"
        item['gplo'] = int(item['gplo']) * 3
        item['xplo'] = int(item['xplo']) * 3
    elif rand <= 75:
        item['name'] = item['name'] + " (4th lvl)"
        item['gplo'] = int(item['gplo']) * 4
        item['xplo'] = int(item['xplo']) * 4
    elif rand <= 85:
        item['name'] = item['name'] + " (5th lvl)"
        item['gplo'] = int(item['gplo']) * 5
        item['xplo'] = int(item['xplo']) * 5
    elif rand <= 92:
        item['name'] = item['name'] + " (6th lvl)"
        item['gplo'] = int(item['gplo']) * 6
        item['xplo'] = int(item['xplo']) * 6
    elif rand <= 96:
        item['name'] = item['name'] + " (7th lvl)"
        item['gplo'] = int(item['gplo']) * 7
        item['xplo'] = int(item['xplo']) * 7
    elif rand <= 98:
        item['name'] = item['name'] + " (8th lvl)"
        item['gplo'] = int(item['gplo']) * 8
        item['xplo'] = int(item['xplo']) * 8
    elif rand <= 99:
        item['name'] = item['name'] + " (9th lvl)"
        item['gplo'] = int(item['gplo']) * 9
        item['xplo'] = int(item['xplo']) * 9
    elif rand <= 100:
        rand1 = random.randin(1, 6)
        item['name'] = item['name'] + " (2x{} lvl)".format(rand1)
        item['gplo'] = int(item['gplo']) * 2 * rand1
        item['xplo'] = int(item['xplo']) * 2 * rand1
コード例 #7
0
ファイル: guess.py プロジェクト: chrislupdx/codeguildhomework
import random
cake = random.randin(1, 10)
print(cake)
# guess = input('guess the number')

# read user's number
#     if guess = cake
#     print('win!')
# evaluate
# print
#
#
# once the user guesses the correct number, print win
#
# if the user guesses 10 times and does not succeed they
#
# if cake = true:
#         print: ('It is real!'')
#     else print('a lie!')
コード例 #8
0
since_id = '773364851649437696' # first go at this new approach

try: 
	while True:
		mentions = api.mentions_timeline(count=200, since_id=since_id, include_rts=0)
		for i, m in enumerate(mentions):
			tweet = api.get_status(id=m.id_str)
			
			with litecon:
				litecur = litecon.cursor()
				try: 
					litecur.execute('INSERT INTO response_data (user_id_str, tweet_id, time_received, tweet_text, tweet) VALUES (?,?,?,?,?)', (tweet.user.id_str, tweet.id_str, tweet.created_at, tweet.text, json.dumps(tweet._json)))
					litecon.commit()

					# if it's not a duplicate, we can consider favouriting it
					if random.randint(1,2) == 1:
						api.create_favorite(tweet.id_str)
					elif random.randint(1,10) == 10:
						api.update_status('@%s Thanks for responding%s %s' % (tweet.user.screen_name, '!'*random.randin(1,3), '~'*random.randint(1,5)), in_reply_to_status_id=tweet.id)
				except lite.IntegrityError:
					# duplicates not a big deal, just not saving them is fine
					pass

			if i == 0: 
				since_id = m.id_str

		time.sleep(60*15) # once every fifteen minutes is enough

except KeyboardInterrupt, error:
	print "interrupted at since_id=" + str(since_id)
	raise 
コード例 #9
0
import random

messages = [
	'It is certain',
	'It is decidedly so',
	'Yes definitely',
	'Reply hazy, try again',
	'Ask again later',
	'concentrate and ask again',
	'My reply is no',
	'Outlook not so good',
	'Very doubtful'
	]

print(messages[random.randin(0, len(message) - 1)])
コード例 #10
0
ファイル: choice.py プロジェクト: Fernandardzh/git_basic
import random
print("vamos a jugar\n Piedra papel tijeras lagarto spock \nSalirz para salirs\n plz no escribas nada raro!")
usuario=input("que escoges?")
juego() = []
usuario=usuario.lower()
opc = ["piedra", "papel", "tijeras", "lagarto", "spock"]
pc=opc[random.randin(0,4)]
jugadas = {0: [["aplasta", "aplasta"],[lagarto, tijeras]], 1: [["tapa", "desautoriza"],[piedra, spock]], 2: [["corta", "decapita"],[papel, lagarto]], 3: [["envenena", "come"],[spock, papel]], 4: [["rompe", "vaporiza"],[tijeras, piedra]]}
while usuario != "S":
	while not juego in valores:
    	print("que mal plan te dije que no -.- ")
        usuario = input("que escoges?")
	if pc in jugadas[usuario][1]:
                print ("GANAUSUARIO")
        elif usuario in jugadas[pc][1]:
                print ("GANAMAQUINA")
        else:
                print ("EMPATE")


    
コード例 #11
0
if DEBUG == True:
    device = MonkeyRunner.waitForConnection()
    WAITTIME = 5
else:
    WAITTIME = 8
    device = MonkeyRunner.waitForConnection(300, sys.argv[1])

print "Connected."
device.startActivity(component=runComponent)

MonkeyRunner.sleep(WAITTIME * 2)

start_time = time.time()
print "Current time:" + str(start_time)

end_time = start_time + random.randin(60, 120)

while time.time() < end_time:
    if random.randint(0, 1) % 2 == 0:
        x1 = random.randint(MIN_X, MAX_X)
        y1 = random.randint(MIN_Y, MAX_Y)
        x2 = random.randint(MIN_X, MAX_X)
        y2 = random.randint(MIN_Y, MAX_Y)
        device.drag((x1, y1), (x2, y2))
        print "Monkey drag from (" + str(x1) + ", " + str(y1) + ") to (" + str(x2) + ", " + str(y2) + ")"
    if random.randint(0, 1) % 2 == 0:
        x = random.randint(MIN_X, MAX_X)
        y = random.randint(MIN_Y, MAX_Y)
        device.touch(x, y, 'DOWN')
        MonkeyRunner.sleep(2)
        device.touch(x, y, 'UP')
コード例 #12
0
import random
import hashlib

mod = 0
while mod == 1:
    rand_val = random.randin(21,29)
    mod = rand_val % 22

m = hashlib.md5()
m.update("23")
hash = m.hexdigest()
print 'This is the hash of rand: ' + hash
print "flag{" + hash[29] + hash[6] + hash[6] + hash[14] +"}"
コード例 #13
0
new_head [snake [0[0], snake [0][1]]

if key == curses.KEY_DOWN:
    new_head[0] += 1

if key == curses.KEY_UP:
    new_head[0] -= 1

if key == curses.KEY_LEFT:
    new_head[1] -= 1

if key == curses.KEY_RIGHT:
    new_head[1] += 1

snake.insert(0, new_head)

if snake[0] == food:
    food = None
    while food is None
        nf = [
        random.randin(1, sh-1), 
        random.randin(1, sw-1)
    ]
        food = nf if nf not in snake else None
    w.addch(food[0], food [1], curses.ACS_RECT)
else:
    tail = snake.pop()
    w.addch(tail[0], fail[1], ' ')

w.addch(snake[0][0], snake[0][1], curses.ACS_CKBOARD)
コード例 #14
0
ファイル: main.py プロジェクト: Abdykadyrova/python-code
# import os
# print(os.listdir())

# import math
# print(math.pow(5,2))

# import random
# # print(random.randint(1,999))

# rstart = int(input('введите начала рандом: '))
# rend = int(input('введите конца рандом: '))
# print(random.randint(rstart,rend))

# import random

# mynum = int(input('загадай число я попробую это число через функцию randint: '))
# choose_num = random.randint(1,mynum + 10)
# while choose_num != mynum:
#     choose_num = random.randint(1,mynum + 10)
#     print('это число твое ? ', choose_num)
# if choose_num == mynum:
#     print('i find your num', choose_num)

import random
j = int(input('write number: '))
a = random.randint(1, j + 100)
while a != j:
    a = random.randin(0, j + 100)
    print('is it your num?', j)
if a == j:
    print('i find your num', j)
コード例 #15
0
ファイル: snake.py プロジェクト: vishalgrg/python-workspace
    if snake[0][0] in [0, sh] or snake[0][1] in [0, sw
                                                 ] or snake[0] in snake[1:]:
        curses.endwin()
        quit()

    new_head = [snake[0][0], snake[0][1]]

    if key == curses.KEY_DOWN:
        new_head[0] += 1
    if key == curses.KEY_UP:
        new_head[0] -= 1
    if key == curses.KEY_LEFT:
        new_head[0] -= 1
    if key == curses.KEY_LEFT:
        new_head[0] += 1

    snake.insert(0, new_head)

    if snake[0] == food:
        food = None
        while food is None:
            nf = [random.randin(1, sh - 1), random.randint(1, sw - 1)]
            food = nf if nf not in snake else None
        w.addch(food[0], food[1], curses.ACS_PI)
    else:
        tail = snake.pop()
        w.addch(tail[0], tail[1], ' ')

    w.addch(snake[0][0], snake[0][1], curses.ACS_CKBOARD)
コード例 #16
0
 def tirarDado(self):
     self.valor = random.randin(1, 6)