forked from JMageeOrg/badCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
61 lines (38 loc) · 1.16 KB
/
main.py
File metadata and controls
61 lines (38 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import os, stat
from cryptography.hazmat.primitives.asymmetric import rsa, dsa
from Crypto.PublicKey import DSA
from socket import socket, AF_INET, SOCK_STREAM, SOCK_NONBLOCK
# Set a file write by others.
temp_file = "/tmp/foo.txt"
os.chmod(temp_file, stat.S_IWOTH)
with open(temp_file, 'r') as f:
print(f)
os.chmod("/tmp/foo.txt", stat.S_IXGRP)
tar_file = '/file.tax*'
os.system(tar_file)
KEY_SIZE = 1024
private_rsa_key = rsa.generate_private_key(
public_exponent=65537,
key_size=KEY_SIZE
)
private_dsa_key = dsa.generate_private_key(
key_size=KEY_SIZE,
)
private_dsa_key_2 = DSA.generate(bits=KEY_SIZE)
assert(private_dsa_key_2 == private_dsa_key)
program = 'a = 5\nb=10\nprint("Sum =", a+b)'
exec(program)
def is_real_user(user="user123", password="Password1"):
return True
sock = socket(
AF_INET,
SOCK_STREAM | SOCK_NONBLOCK)
# Bind the socket to the internet with a port number
sock.bind(("::", 32007))
def add_server_port(sg, server_name, port):
server = _get_server(sg, server_name, port)
if server is not None:
return False
set_port(port)
return server
add_server_port('security-group', 'server', 80)