o1, тест Тьюринга, экономический эффект AI
1 week ago
Esprit curieux
import struct import platform is_x64 = platform.architecture()[0] == '64bit' if is_x64: SHIFT = 30 digit_size = struct.calcsize('I') else: SHIFT = 15 digit_size = struct.calcsize('H') def restore_python_long(): """ Restore python long integer value from memory """ # hard coded data bytes from memory if is_x64: ob_size_data_str = '05 00 00 00 00 00 00 00' ob_digit_data_str = '11 11 00 00 fc ff bb 3b de dd cd 0c f3 ee ae 2a aa 00 00 00' else: ob_size_data_str = '09 00 00 00' ob_digit_data_str = '11 11 00 00 fc 7f 77 77 de 5d 9b 19 f3 6e 5d 55 aa 00' ob_size_data = ob_size_data_str.replace(' ', '').decode('hex') ob_digit_data = ob_digit_data_str.replace(' ', '').decode('hex') # get ob_size if is_x64: ob_size = struct.unpack('q', ob_size_data)[0] else: ob_size = struct.unpack('i', ob_size_data)[0] if ob_size == 0: return 0L # get digits digits = [] for i in xrange(0, abs(ob_size)): digit_value = ob_digit_data[i * digit_size: i * digit_size + digit_size] if is_x64: digits.append(struct.unpack('I', digit_value)[0]) else: digits.append(struct.unpack('H', digit_value)[0]) # restore long value = 0L for i in xrange(0, abs(ob_size)): value += digits[i] * 2 ** (SHIFT * i) if ob_size < 0: value = -value return value value = restore_python_long() print hex(value) print valueAnd the result is the same as input:
from PIL import Image, ImageChops image1 = Image.open('pic1.jpg') image2 = Image.open('pic2.jpg') diff = ImageChops.difference(image1, image2) diff.save('diff.jpg')
import java.io.PrintStream; import java.math.BigInteger; public class guess { public guess() { } static String XOR(String _str_one, String _str_two) { BigInteger i1 = new BigInteger(_str_one, 16); BigInteger i2 = new BigInteger(_str_two, 16); BigInteger res = i1.xor(i2); String result = res.toString(16); return result; } public static void main(String args[]) { int guess_number = 0; int my_num = 0x14d8f707; int my_number = 0x5c214f6c; int flag = 0x149b861a; if(args.length > 0) { try { guess_number = Integer.parseInt(args[0]); if(my_number / 5 == guess_number) { String str_one = "4b64ca12ace755516c178f72d05d7061"; String str_two = "ecd44646cfe5994ebeb35bf922e25dba"; my_num += flag; String answer = XOR(str_one, str_two); System.out.println((new StringBuilder("your flag is: ")).append(answer).toString()); } else { System.err.println("wrong guess!"); System.exit(1); } } catch(NumberFormatException e) { System.err.println("please enter an integer \nexample: java -jar guess 12"); System.exit(1); } } else { System.err.println("wrong guess!"); int num = 0xf4240; num++; System.exit(1); } } }
print '%x' % (0x4b64ca12ace755516c178f72d05d7061 ^ 0xecd44646cfe5994ebeb35bf922e25dba)
print ''.join(map(chr, [0x20, 0x64, 0x65, 0x36, 0x38, 0x33, 0x38, 0x32, 0x35, 0x32, 0x66, 0x39, 0x35, 0x64, 0x33, 0x62, 0x39, 0x65, 0x38, 0x30, 0x33, 0x62, 0x32, 0x38, 0x64, 0x66, 0x33, 0x33, 0x62, 0x34, 0x62, 0x61, 0x61, 0x00]))
# read data data = [] with open('hidden-message.pcap', 'rb') as f: data = f.read() # get bits bits = '' for i in xrange(75, len(data), 81): bits += '0' if data[i:i+1]=='I' else '1' # convert to chars flag = '' for i in xrange(0, len(bits), 8): flag += chr(int(bits[i:i+8], 2)) print flag
from PIL import Image # solved sudoku s = ''' 964127538 712385694 385496712 491578263 238614975 576239841 627843159 153962487 849751326 ''' s = s.replace('\n', '') image = Image.open('image.png').convert('RGB') out_image = Image.new('RGB', image.size) for j in xrange(0, 9): for i in xrange(0, 9): img_cell = image.crop((i * 50, j * 50, i * 50 + 50, j * 50 + 50)) # get pos (column) column = (int(s[j * 9 + i]) - 1) * 50 out_image.paste(img_cell, (column, j * 50)) out_image.save('out_image.png')
class A(object): """Class A""" def foo(self): """Function foo""" pass A.__doc__ = 'A class'
static PyGetSetDef type_getsets[] = { ... {"__doc__", (getter)type_get_doc, NULL, NULL}, ... }
a = A() a.__doc__ = 'A' print a.__doc__ A print A.__doc__ Class A
class A(object): """Class A""" def foo(self): """Function foo""" print 'A.foo()' def update_class_doc(cls, new_doc): new_dict = dict(cls.__dict__) new_dict['__doc__'] = new_doc new_cls = type(cls.__name__, A.__bases__, new_dict) return new_cls A = update_class_doc(A, 'Updated docstring of class A')
print A.__doc__
Updated docstring of class A
A.foo.__doc__ = 'Updated docstring of foo'
static PyGetSetDef instancemethod_getset[] = { {"__doc__", (getter)instancemethod_get_doc, NULL, NULL}, {0} };
print A.foo.__doc__ Function foo A.foo.__func__.__doc__ = 'Updated docstring of foo' print A.foo.__doc__ Updated docstring of foo
A.foo.im_func.__doc__ = 'Updated docstring of foo 2' print A.foo.__doc__ Updated docstring of foo 2
static PyGetSetDef type_getsets[] = { ... {"__doc__", (getter)type_get_doc, (setter)type_set_doc, NULL}, ... }
A.__doc__ = 'A class'
import struct data = 'Oqiqb4EhM/4jISMjlzQf6kpGQwLrG+GEIY4bPc0JL/jWBfNLejmbme3garIrG4ngbXtWQY3Y2VdbvRxleHU9aGxFRLXkh5BDGVbm5gAAhGeBMBl65XKmZ9sbNn4xxi3cbD7M02MpwZ3BpN4lG3xyFPsofbhXbMu8Z/1rlqfdul/KLaGmkllOYRj9Mhnumqw1f464dK948rgz5JxpeSQHN45GlMNjb717x6IeCCMa6gN+YX73M/LrkH1xZEhpjZ4YLugpHGquVl9m5Kq7AvcapkVEUsZt29JWB/dzq//bFG15ykd53wpP/8gddTTwV6i2vmLXLjDrfwO4NCLolYyD78vmdPsZRvlI4B0bslHerN7buJ938iWcaKg6NjrHMfZhO6BrvbLRbhSUQSKfgyXsAhaT/O1p1fM6KoFlWbHri9HfIwKocjXQkUDsT2u7U2+82oYHVvhthhCOlxlQyiUKr11Cj9Pzbqz11sulpr0D0rfChHOO81Ht3ax1ynL/nTQmNWCj4U4C0T9cjmUNU47gdGMEa0+tyv2s75/Xvo+qTrywdVqLDEviE+3Gxy3U+vX5MRrJipxK2OnUu/g/uanoLok7CA4LKQe7+ho6Vrb91/K/scyEdIvUlZ5A3LfP3DRWsE4LbKkYcwUy6ea7aEqdaEqd6ea7cwUybKkYsE4L3DRW3LfPlZ5AdIvUscyE1/K/Vrb9+ho6KQe7CA4LLok7uanou/g/2OnUipxKMRrJ+vX5xy3UE+3GDEvidVqLTrywvo+q75/Xyv2sa0+tdGMEU47gjmUN0T9c4U4CNWCjnTQmynL/3ax181HthHOO0rfCpr0D1sulbqz1j9Pzr11CyiUKlxlQhhCOVvht2oYHU2+8T2u7kUDscjXQIwKoi9HfWbHrKoFl1fM6/O1pAhaTgyXsQSKfbhSUvbLRO6BrMfZhNjrHaKg68iWcuJ93rN7bslHe4B0bRvlIdPsZ78vmlYyDNCLofwO4LjDrvmLXV6i2dTTw/8gd3wpPykd5FG15q//bB/dz29JWUsZtpkVEAvca5Kq7Vl9mHGquLugpjZ4YZEhpkH1xM/LrYX736gN+CCMax6Ieb717lMNjN45GeSQH5Jxp8rgzdK94f464mqw1MhnuYRj9kllOLaGmul/KlqfdZ/1rbMu8fbhXFPsoG3xypN4lwZ3B02MpbD7Mxi3cNn4xZ9sb5XKmMBl6hGeB5gAAGVbmh5BDRLXkaGxFeHU9vRxl2VdbQY3YbXtWG4ngarIrme3gejmbBfNLL/jWPc0JIY4bG+GEQwLr6kpGlzQfISMjM/4jb4EhOqiq' def invert(x): return ~x & 0xffffffff def decode_func(key, value): return (value & (invert(key + 1) + 1)) + (key & (invert(value + 1) + 1)) def checker(key): result = key for i in xrange(0, len(data), 4): value = struct.unpack('I', data[i:i+4])[0] result = decode_func(result, value) return result key = checker(0x7a2896bf) print 'The key is: %s' % key