Skip to content

Changing python header #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 0ctf2019/babyrsa/secret.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

flag= open("/flag", "rb").read().strip()
2 changes: 1 addition & 1 deletion 0ctf2021quals/cloudpass/task
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

import os
import socketserver
Expand Down
2 changes: 1 addition & 1 deletion 0ctf2021quals/zer0lfsr/task
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

import random
import signal
Expand Down
2 changes: 1 addition & 1 deletion 0x41414141ctf2021/factorize/factorize
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

import binascii
import random
Expand Down
2 changes: 1 addition & 1 deletion 0x41414141ctf2021/filereader/filereader
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

import glob

Expand Down
2 changes: 1 addition & 1 deletion 0x41414141ctf2021/pyjail/pyjail
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

import re
from sys import modules, version
Expand Down
2 changes: 1 addition & 1 deletion 0x41414141ctf2021/soul/net
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

import os
import socketserver
Expand Down
174 changes: 87 additions & 87 deletions 0x41414141ctf2021/staple-aes/aes
Original file line number Diff line number Diff line change
@@ -1,88 +1,88 @@
#!/opt/pwn.college/python
import os
import socketserver
import string
import threading
from time import *
import random
import time
import binascii
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
iv = b''
key = b''
flag = open("/flag", "r").read().strip()
class Service(socketserver.BaseRequestHandler):
def handle(self):
assert len(flag) % 16 == 1
blocks = self.shuffle(flag)
ct = self.encrypt(blocks)
self.send(binascii.hexlify(ct))
def byte_xor(self, ba1, ba2):
return bytes([_a ^ _b for _a, _b in zip(ba1, ba2)])
def encrypt(self, blocks):
curr = iv
ct = []
cipher = AES.new(key, AES.MODE_ECB)
for block in blocks:
curr = cipher.encrypt(curr)
ct.append(self.byte_xor(block, curr))
return b''.join(ct)
def shuffle(self, pt):
pt = pad(pt, 16)
pt = [pt[i: i + 16] for i in range(0, len(pt), 16)]
random.shuffle(pt)
return pt
def send(self, string, newline=True):
if type(string) is str:
string = string.encode("utf-8")
if newline:
string = string + b"\n"
self.request.sendall(string)
def receive(self, prompt="> "):
self.send(prompt, newline=False)
return self.request.recv(4096).strip()
class ThreadedService(
socketserver.ThreadingMixIn,
socketserver.TCPServer,
socketserver.DatagramRequestHandler,
):
pass
def main():
port = 3167
host = "0.0.0.0"
service = Service
server = ThreadedService((host, port), service)
server.allow_reuse_address = True
server_thread = threading.Thread(target=server.serve_forever)
server_thread.daemon = True
server_thread.start()
print("Server started on " + str(server.server_address) + "!")
# Now let the main thread just wait...
while True:
sleep(10)
if __name__ == "__main__":
#!/usr/bin/exec-suid -- /usr/bin/python3

import os
import socketserver
import string
import threading
from time import *
import random
import time
import binascii

from Crypto.Cipher import AES
from Crypto.Util.Padding import pad

iv = b''
key = b''
flag = open("/flag", "r").read().strip()

class Service(socketserver.BaseRequestHandler):

def handle(self):
assert len(flag) % 16 == 1
blocks = self.shuffle(flag)
ct = self.encrypt(blocks)
self.send(binascii.hexlify(ct))

def byte_xor(self, ba1, ba2):
return bytes([_a ^ _b for _a, _b in zip(ba1, ba2)])

def encrypt(self, blocks):
curr = iv
ct = []
cipher = AES.new(key, AES.MODE_ECB)
for block in blocks:
curr = cipher.encrypt(curr)
ct.append(self.byte_xor(block, curr))
return b''.join(ct)

def shuffle(self, pt):
pt = pad(pt, 16)
pt = [pt[i: i + 16] for i in range(0, len(pt), 16)]
random.shuffle(pt)
return pt

def send(self, string, newline=True):
if type(string) is str:
string = string.encode("utf-8")

if newline:
string = string + b"\n"
self.request.sendall(string)

def receive(self, prompt="> "):
self.send(prompt, newline=False)
return self.request.recv(4096).strip()


class ThreadedService(
socketserver.ThreadingMixIn,
socketserver.TCPServer,
socketserver.DatagramRequestHandler,
):
pass


def main():

port = 3167
host = "0.0.0.0"

service = Service
server = ThreadedService((host, port), service)
server.allow_reuse_address = True

server_thread = threading.Thread(target=server.serve_forever)

server_thread.daemon = True
server_thread.start()

print("Server started on " + str(server.server_address) + "!")

# Now let the main thread just wait...
while True:
sleep(10)


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion 0x41414141ctf2021/wallet/wallet
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

import os
import socketserver
Expand Down
2 changes: 1 addition & 1 deletion accessdeniedctf2022/ecc/chal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

import tinyec.ec as ec
import tinyec.registry as reg
Expand Down
2 changes: 1 addition & 1 deletion angstromctf2016/casino/casino
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

#seed = 9519
#flag = "actf{Men_Are_maSTers_of_thEiR_fateS}"
Expand Down
2 changes: 1 addition & 1 deletion angstromctf2016/helpcenter/server
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

key = 'c342cb3177881464'
IV = 'ca302100528f5ef9'
Expand Down
2 changes: 1 addition & 1 deletion angstromctf2017/casino/card_guessing
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

import os,struct

Expand Down
2 changes: 1 addition & 1 deletion angstromctf2017/royalcasino/casino
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

import os,struct

Expand Down
2 changes: 1 addition & 1 deletion angstromctf2022/randomlysampledalgorithm/rsa
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

from Crypto.Util.number import getStrongPrime

Expand Down
2 changes: 1 addition & 1 deletion angstromctf2024/philosophy/chall
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

from Crypto.Util.number import getPrime
#from secret import flag
Expand Down
2 changes: 1 addition & 1 deletion angstromctf2024/presidential/source
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

import ctypes
import mmap
Expand Down
2 changes: 1 addition & 1 deletion angstromctf2024/tss1/tss1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

from hashlib import sha256
import fastecdsa.curve
Expand Down
2 changes: 1 addition & 1 deletion angstromctf2024/tss2/tss2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

from hashlib import sha256
import fastecdsa.curve
Expand Down
2 changes: 1 addition & 1 deletion byuctf2022/blue/create.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

from PIL import Image
import random
Expand Down
2 changes: 1 addition & 1 deletion byuctf2024/aresa/keygen
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

from Crypto.Util.number import bytes_to_long, getPrime

Expand Down
2 changes: 1 addition & 1 deletion byuctf2024/domath/domath
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

from Crypto.Util.number import *

Expand Down
2 changes: 1 addition & 1 deletion byuctf2024/giveup/nevergonna
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/bin/python3

def repeat_key_xor(plain, key): # take in bytes
output = b''
Expand Down
Loading