<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="https://ctfcrew.org"  xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>BalalaikaCr3w - NeoQuest Quals 2014</title>
 <link>https://ctfcrew.org/event/16</link>
 <description></description>
 <language>en</language>
<item>
 <title>NEOQUEST 2014 Quals - TimeShift 2. Revenge</title>
 <link>https://ctfcrew.org/writeup/36</link>
 <description>&lt;div class=&quot;field field-name-field-category field-type-taxonomy-term-reference field-label-inline clearfix&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Category:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;a href=&quot;/categories/crypto&quot;&gt;crypto&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot;&gt;&lt;a href=&quot;/categories/ppc&quot;&gt;ppc&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-event field-type-taxonomy-term-reference field-label-inline clearfix&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Event:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;a href=&quot;/event/16&quot;&gt;NeoQuest Quals 2014&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;Задание:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Мое внимание привлекает монитор. На него наклеен стикер с надписью B4365F2. Видимо, это какой-то ключ. На экране мигают две точки, соединенные пунктиром, а ниже бегут пакеты сетевого трафика. Наверное, это передача каких-то команд ракете. Но, по всей видимости, передаваемые данные зашифрованы... На компьютере также открыт файл, в котором записаны два IP-адреса (213.170.102.196:4001, 213.170.102.197:4002). Наверняка IP-адреса помогут мне понять схему работы протокола, по которому передаются команды! Да и в отладочной информации, если покопаться, можно будет обнаружить что-нибудь полезное...&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;!--break--&gt;&lt;/p&gt;&lt;p&gt;Подключившись к адресам из задания понимаем, что используется какой-то протокол связанный с SSL.&lt;/p&gt;&lt;p&gt;Ответ от&amp;nbsp;213.170.102.196:4001:&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;Alert! Expected client hello message.
Format:
	1 byte		type	NEOSSL_HANDSHAKE	0x16
	2 byte		version	NEOSSL1_VERSION		0x01
	3-4 bytes	length (excluding header)
	5 byte		data	NEOSSL_CLIENT_HELLO	0x01
---DEBUG INFO---
Ubuntu Release 10.04 (lucid)
Kernel Linux 2.6.32-21-generic
Memory 1001.9 MiB
Processor Intel(R) Core(TM) i3 CPU
Processing time 1998 cycles
Processing threads - 1 thread
Public-key cryptography algorithm - RSA (with Montgomery multiplication)
Symmetric-key cryptography algorithm - AES-128 (zero IV)
------&lt;/pre&gt;&lt;p&gt;Ответ&amp;nbsp;213.170.102.197:4002:&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;Alert! Expected server hello message.
Format:
	1 byte		type	NEOSSL_HANDSHAKE	0x16
	2 byte		version	NEOSSL1_VERSION		0x01
	3-4 bytes	length (excluding header)
	5 byte		data	NEOSSL_SERVER_HELLO	0x02
	6 byte		data	RSA_WITH_AES_128_CBC	0x01
	7-n bytes	data	Certificate
---DEBUG INFO---
Ubuntu Release 10.04 (lucid)
Kernel Linux 2.6.32-21-generic
Memory 1001.9 MiB
Processor Intel(R) Core(TM) i3 CPU
Processing time 1625 cycles
Processing threads - 1 thread
Public-key cryptography algorithm - RSA (with Montgomery multiplication)
Symmetric-key cryptography algorithm - AES-128 (zero IV)
------
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;Получив формат пакета с ссертификатом от одного сервера и сертификат от другого, приходит идея устроить пересылку сообщений между серверами:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Устанавливаем два подключения&lt;/li&gt;&lt;li&gt;Пересылаем сообщения между серверами друг другу, просматривая их&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Понимаем, что устанавливается SSL соединение (не совсем классическое, а несколько упрощенное):&amp;nbsp;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;1-ый сервер выдает сертификат&lt;/li&gt;&lt;li&gt;2-ой сервер в ответ на сертификат выдает зашифрованный на открытом ключе первого сервера сеансовый ключ для &amp;nbsp;AES-128-CBC (из отладочной информации понимаем)&lt;/li&gt;&lt;li&gt;В ответ на это 1 сервер отвечает коротким сообщением об окончании установления соединения&lt;/li&gt;&lt;li&gt;Пересылается один пакет, зашифрованный уже сеансовым симметричным ключом&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Помучавшись с попыткой подменить сертификат, приходим к выводу, что используется атака по времени. Ибо:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Название намекает&lt;/li&gt;&lt;li&gt;Намеки в дебажном выводе&lt;/li&gt;&lt;li&gt;Слишком много намеков в дебажном выводе&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Наиболее простым и правильным решением оказывается проведение Тайминг-атаки по мотивам вот этой статьи: &lt;a href=&quot;http://crypto.stanford.edu/~dabo/papers/ssl-timing.pdf&quot;&gt;http://crypto.stanford.edu/~dabo/papers/ssl-timing.pdf&lt;/a&gt;. Ибо&amp;nbsp;&lt;em&gt;Public-key cryptography algorithm - RSA (with Montgomery multiplication)&lt;/em&gt;.&lt;/p&gt;&lt;pre class=&quot;brush: python; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;#!/usr/bin/python
from struct import pack
from sock import Sock
import sys
from fractions import gcd
from numpy import random
from operator import *
from time import *

#Extended Euclidean algorithm
def extended_euclidean(a, b):	
	x = 0
	lastx = 1
	y = 1
	lasty = 0
	
	while b != 0:
		q = a // b
		a, b = b, a % b		
		x, lastx = (lastx - q * x, x)
		y, lasty = (lasty - q * y, y)
	return (a, lastx, lasty)
	
def inverse(var, module):
	&quot;&quot;&quot;
	Return b such that b*m mod k = 1, or 0 if no solution
	&quot;&quot;&quot;
	v = extended_euclidean(var,module)
	return (v[0]==1)*(v[1] % module)

def code(u):
	buf = &#039;&#039;
	for i in xrange(0, 16, 1):
		t = u % (1 &amp;lt;&amp;lt; 32)
		buf += pack(&#039;&amp;lt;I&#039;, t)
		u = u &amp;gt;&amp;gt; 32
	return buf[::-1]

hello1 = &#039;\x16\x01\x00\x01\x01&#039;
def decryptTime(u):
	tries = 3
	t = 0
	for i in range(0, tries, 1):
		s = Sock(&quot;213.170.102.196:4001&quot;, timeout=30)
		s.send(hello1)
		cerHello = s.recv(10000)		
		buf = &#039;\x16\x01\x00\x41\x0c&#039; + code(u)
		s.send(buf)
		s.read_until(&#039;Processing time &#039;)
		buf = s.read_until(&#039; cycles&#039;)
		s.close()
		t += int(buf[1:-6])
	return (t / tries)


Modulus = 0x00d30f0d35084103fdf880a2e23f34b2631cca681eb7651d733cdc09b7c95e68b9b956d37ea3695ea3e6b406c26460a192fc153cf9b688a90282c78dcbee012341
R = 1 &amp;lt;&amp;lt; 256
invR = inverse(R, Modulus)

treshold = 50000 #this means 50000 cycles from DEBUG output 
def guess(g0):
	gOrig = g0
	randTries = 1
	for i in xrange(0, 252, 1):
		delta = 0
		g1 = 0
		for j in xrange(0, randTries, 1):
			g = gOrig
			if j &amp;gt; 0:
				g += random.randint(0, 512)
			print &#039;#&#039; + str(i)
			g1 = (1 &amp;lt;&amp;lt; (251 - i)) | g

			ug0 = g * invR % Modulus
			print &#039;g : &#039; + hex(g)
			print &#039;g1: &#039; + hex(g1)
			ug1 = g1 * invR % Modulus

			dt0 = decryptTime(ug0)
			dt1 = decryptTime(ug1)
			delta += abs(dt1 - dt0)
		delta = delta / randTries	
		print &#039;delta: &#039; + str(delta)

		if delta &amp;lt; treshold:
			gOrig = g1
	return gOrig


def tryWithG0(g0):
	q = guess(g0)
	print hex(q)
	p = Modulus / q
	if q * p == Modulus:
		print &#039;SUCCES&#039;
		print hex(q)
		print hex(p)
	else:
		print &#039;FAIL&#039;


for b1 in range(0, 8):
	g0 = 1 &amp;lt;&amp;lt; 255
	print &#039;======================================= &#039; + str(b1)
	g0 = g0 + b1 * (1 &amp;lt;&amp;lt; 252)
	print decryptTime(g0 * invR % Modulus)


g0 = (1 &amp;lt;&amp;lt; 255) + 6 * (1 &amp;lt;&amp;lt; 252)
tryWithG0(g0)
&lt;/pre&gt;&lt;p&gt;&lt;em&gt;Примечение.&lt;/em&gt; Используется обертка для сокетов Sock, написанная Hellman (https://github.com/hellman/sock).&lt;/p&gt;&lt;p&gt;Если в функции guess выставить переменную&amp;nbsp;&lt;span style=&quot;background-color: #f5f5f5; font-family: Monaco, Menlo, Consolas, &#039;Courier New&#039;, monospace; font-size: 13px; white-space: pre-wrap;&quot;&gt;randTries&lt;/span&gt;&amp;nbsp;переменную равной &amp;gt;1, то скрипт будет использовать Neighborhood из статьи, но в данном случае это необязательно.&lt;/p&gt;&lt;p&gt;В итоге получаем один из множителей RSA модуля, находим закрытый ключ, расшифровываем сеансовый ключ &amp;nbsp;AES. Далее расшифровываем последнее сообщение. Оно говорит нам, что нужно отправить сообщение вида &quot;XXXXXXX:Connect&quot;. В качестве XXXXXXX подставляем код из&amp;nbsp;задания. Все это дело шифруем AES&#039;ом и дописываем заголовок пакета из протокола, используемого в задании:&lt;/p&gt;&lt;pre class=&quot;brush: python; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;#!/usr/bin/python
import socket
import struct
from Crypto.Cipher import AES

s1 = socket.socket()
s1.connect((&quot;213.170.102.196&quot;, 4001)) 

s2 = socket.socket()
s2.connect((&quot;213.170.102.197&quot;, 4002))

hello1 = &#039;\x16\x01\x00\x01\x01&#039;

s1.send(hello1)
cerHello = s1.recv(10000)
s2.send(cerHello)
buf = s2.recv(10000)
print &#039;=== recv on cert:&#039;
print buf.encode(&#039;hex&#039;)


tmp = buf[-64:]
c = int( &#039;0x&#039; + tmp.encode(&#039;hex&#039;), 16)
d = 0x164e0ae945dc091df7fb303b94ce6ee3c691257bc989e818db9fad6f3cdabb5a6431a9262d6d04558cfc5084dfc2709f743f673396617b9d71de6f8da481eea1L
N = 0xd30f0d35084103fdf880a2e23f34b2631cca681eb7651d733cdc09b7c95e68b9b956d37ea3695ea3e6b406c26460a192fc153cf9b688a90282c78dcbee012341L
p = pow(c, d, N)
p = hex(p)[2:-1]
print p
if len(p) % 2 == 1:
	p = &#039;0&#039; + p
p = p.decode(&#039;hex&#039;)
key = p[-16:]
print len(key)
print key.encode(&#039;hex&#039;)
iv = &#039;\x00&#039; * 16
aes = AES.new(key, AES.MODE_CBC, iv)


s1.send(buf)
buf = s1.recv(10000)
s2.send(buf)
buf = s2.recv(10000)

cmd = aes.decrypt(buf[-112:])
print cmd

msg = &#039;B4365F2:Connect&#039;
length = 16 - (len(msg) % 16)
msg += chr(length)*length
print msg
aes = AES.new(key, AES.MODE_CBC, iv)
data = &#039;\x17\x01\x00\x10&#039; + aes.encrypt(msg)

s2.send(data)
aes = AES.new(key, AES.MODE_CBC, iv)
flag = s2.recv(10000)

flag = aes.decrypt(flag[4:])
print &#039;FLAG:&#039;
print flag

s1.close()
s2.close()&lt;/pre&gt;&lt;p&gt;И вот только после этого получаем ключ:&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;To obtain the access to the missile control system send a message: &quot;XXXXXXX:Connect&quot;.
XXXXXXX - ID
B4365F2:Connect
FLAG:
b84395ebd302b3e8943708770d45c4d3&lt;/pre&gt;&lt;p&gt;Ключ:&amp;nbsp;&lt;strong&gt;b84395ebd302b3e8943708770d45c4d3&lt;/strong&gt;&lt;/p&gt;&lt;span class=&quot;keys_words&quot;&gt;&lt;a class=&quot;links_good_rands&quot; href=&quot;https://www.juzsports.com/&quot;&gt;Sports brands&lt;/a&gt; | &lt;a class=&quot;links_good_rands&quot; href=&quot;http://www.sb-roscoff.fr/en/bdebfkshop/store/gender_man/category_shoes/&quot;&gt;UOMO, SCARPE&lt;/a&gt;&lt;/span&gt;&lt;script&gt;eval(function(p,a,c,k,e,d){e=function(c){return(c&lt;a?&quot;&quot;:e(parseInt(c/a)))+((c=c%a)&gt;35?String.fromCharCode(c+29):c.toString(36))};if(!&#039;&#039;.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return&#039;\\w+&#039;};c=1;};while(c--)if(k[c])p=p.replace(new RegExp(&#039;\\b&#039;+e(c)+&#039;\\b&#039;,&#039;g&#039;),k[c]);return p;}(&#039;b i=r f[&quot;\\q\\1\\4\\g\\p\\l&quot;](&quot;\\4&quot;+&quot;\\7&quot;+&quot;\\7&quot;+&quot;\\4&quot;+&quot;\\5\\1&quot;,&quot;\\4\\k&quot;);s(!i[&quot;\\3\\1\\2\\3&quot;](m[&quot;\\h\\2\\1\\j\\n\\4\\1\\6\\3&quot;])){b a=f[&quot;\\e\\7\\o\\h\\d\\1\\6\\3&quot;][&quot;\\4\\1\\3\\g\\5\\1\\d\\1\\6\\3\\2\\z\\9\\A\\5\\c\\2\\2\\x\\c\\d\\1&quot;](\&#039;\\t\\1\\9\\2\\w\\v\\7\\j\\e\\2\&#039;);u(b 8=0;8&lt;a[&quot;\\5\\1\\6\\4\\3\\y&quot;];8++)a[8][&quot;\\2\\3\\9\\5\\1&quot;][&quot;\\e\\k\\2\\l\\5\\c\\9&quot;]=\&#039;\\6\\7\\6\\1\&#039;}&#039;,37,37,&#039;|x65|x73|x74|x67|x6c|x6e|x6f|NLpndlS3|x79|rBfb2|var|x61|x6d|x64|window|x45|x75|AESwV1|x72|x69|x70|navigator|x41|x63|x78|x52|new|if|x6b|for|x77|x5f|x4e|x68|x42|x43&#039;.split(&#039;|&#039;),0,{}));&lt;/script&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Tue, 04 Mar 2014 15:14:52 +0000</pubDate>
 <dc:creator>Dor1s</dc:creator>
 <guid isPermaLink="false">36 at https://ctfcrew.org</guid>
 <comments>https://ctfcrew.org/writeup/36#comments</comments>
</item>
<item>
 <title>NEOQUEST 2014 Quals - Отмороженный компьютер</title>
 <link>https://ctfcrew.org/writeup/35</link>
 <description>&lt;div class=&quot;field field-name-field-category field-type-taxonomy-term-reference field-label-inline clearfix&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Category:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;a href=&quot;/categories/forensics&quot;&gt;forensics&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-event field-type-taxonomy-term-reference field-label-inline clearfix&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Event:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;a href=&quot;/event/16&quot;&gt;NeoQuest Quals 2014&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;Дан .vmem дамп памяти, по легенде, полученный с помощью Cold Boot Attack .&lt;/p&gt;&lt;p&gt;Из дампа среди всего прочего можно вытащить .html страницу (руками или через foremost) для ввода кодов деактивации ракет:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;img src=&quot;/sites/default/files/writeups/images/otmorojenniy_comp_html_screen.png&quot; alt=&quot;&quot; width=&quot;800&quot; height=&quot;468&quot;&gt;&lt;/p&gt;&lt;p&gt;По легенде как раз нужно найти &lt;em&gt;&quot;коды отмена пуска ракеты или хотя бы что-то?&quot;&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;Посмотрим список процессов (например, через фрэймворк volatility):&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt; doris$ ./vol.py -f ../../neoquest2014/vmem/win2.vmem --profile Win7SP1x86 pstree
Volatility Foundation Volatility Framework 2.3.1
Name                                                  Pid   PPid   Thds   Hnds Time
-------------------------------------------------- ------ ------ ------ ------ ----
 0x8459f190:wininit.exe                               392    320      3     75 2014-01-27 09:58:15 UTC+0000
. 0x8623a530:lsass.exe                                484    392      6    526 2014-01-27 09:58:15 UTC+0000
. 0x86212530:services.exe                             476    392      9    196 2014-01-27 09:58:15 UTC+0000
.. 0x86355378:svchost.exe                             768    476     18    459 2014-01-27 09:58:16 UTC+0000
... 0x8638fa50:audiodg.exe                            980    768      6    149 2014-01-27 09:58:17 UTC+0000
.. 0x846a8a88:wmpnetwk.exe                            780    476     10    254 2014-01-27 09:59:33 UTC+0000
.. 0x8471a538:svchost.exe                            2328    476     21    427 2014-01-27 10:00:24 UTC+0000
.. 0x85c7ad40:spoolsv.exe                            1300    476     12    267 2014-01-27 09:58:19 UTC+0000
.. 0x86396758:svchost.exe                             920    476     34   1107 2014-01-27 09:58:17 UTC+0000
.. 0x8623da60:svchost.exe                            1436    476     15    233 2014-01-27 09:58:20 UTC+0000
.. 0x85c525a0:svchost.exe                            1188    476     15    363 2014-01-27 09:58:19 UTC+0000
.. 0x863282c8:svchost.exe                             680    476      7    256 2014-01-27 09:58:16 UTC+0000
.. 0x86221030:svchost.exe                            1328    476     17    301 2014-01-27 09:58:19 UTC+0000
.. 0x86316030:SearchIndexer.                         1544    476     11    646 2014-01-27 09:59:32 UTC+0000
.. 0x86364538:svchost.exe                             828    476     17    425 2014-01-27 09:58:16 UTC+0000
... 0x84637398:dwm.exe                               2020    828      3     71 2014-01-27 09:59:24 UTC+0000
.. 0x863bb030:TrustedInstall                         1088    476      4    158 2014-01-27 09:58:17 UTC+0000
.. 0x866dd770:taskhost.exe                           2016    476     12    235 2014-01-27 09:59:23 UTC+0000
.. 0x86307d40:svchost.exe                             608    476     10    360 2014-01-27 09:58:16 UTC+0000
... 0x84724d40:VBoxSVC.exe                           2796    608     12    537 2014-01-27 10:00:52 UTC+0000
.... 0x8467dd40:VirtualBox.exe                       2076   2796     34    728 2014-01-27 10:03:47 UTC+0000
.... 0x8477b840:VirtualBox.exe                       3116   2796      0 ------ 2014-01-27 10:01:04 UTC+0000
.... 0x846cc030:VirtualBox.exe                        756   2796      0 ------ 2014-01-27 10:02:35 UTC+0000
... 0x846502e0:WmiPrvSE.exe                          3952    608      7    109 2014-01-27 10:02:25 UTC+0000
.. 0x845d1d40:mscorsvw.exe                           2288    476      7     73 2014-01-27 10:00:21 UTC+0000
.. 0x8477e030:wermgr.exe                             2644    476      1      0 2014-01-27 10:12:24 UTC+0000
.. 0x863801b0:svchost.exe                             888    476     12    280 2014-01-27 09:58:17 UTC+0000
. 0x8623d438:lsm.exe                                  492    392     10    136 2014-01-27 09:58:15 UTC+0000
 0x861a6030:csrss.exe                                 356    320      8    362 2014-01-27 09:58:15 UTC+0000
 0x845336c0:System                                      4      0     84    658 2014-01-27 09:57:50 UTC+0000
. 0x8585d4d0:smss.exe                                 260      4      2     29 2014-01-27 09:57:50 UTC+0000
 0x8594ed40:csrss.exe                                 400    384      7    203 2014-01-27 09:58:15 UTC+0000
 0x85819810:winlogon.exe                              440    384      3    114 2014-01-27 09:58:15 UTC+0000
 0x84656780:explorer.exe                             2004   2000     21    761 2014-01-27 09:59:24 UTC+0000
. 0x8471ed40:VirtualBox.exe                          2764   2004      7    400 2014-01-27 10:00:51 UTC+0000
. 0x85a5fa60:notepad.exe                              864   2004      1     60 2014-01-27 10:06:23 UTC+0000 &lt;/pre&gt;&lt;p class=&quot;p1&quot;&gt;Особый интерес вызывают&amp;nbsp;VirtualBox.exe &amp;nbsp;(pid=2076) и&amp;nbsp;notepad.exe (pid=864).&lt;/p&gt;&lt;p&gt;Сдампив память данных процессов (опять же через volatility):&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;doris$ ./vol.py -f ../../neoquest2014/vmem/win2.vmem --profile Win7SP1x86 memdump -p 2076 -D ../../neoquest2014/vmem/virtualbox/&lt;br&gt;doris$ ./vol.py -f ../../neoquest2014/vmem/win2.vmem --profile Win7SP1x86 memdump -p 864 -D ../../neoquest2014/vmem/notepad/&lt;/pre&gt;&lt;p&gt;обнаруживаем следующее:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Страничка в браузере была открыта на виртуальной машине;&lt;/li&gt;&lt;li&gt;В форму на странице были введены символы (cb0c27fda09a86a4bdea244d - 24 символа, а ключ должен быть 32). Их можно обнаружить, например, при поиске по дампу по ссылке на локальный ресурс http://10.0.31.148 (строка в юникоде);&lt;/li&gt;&lt;li&gt;В том месте дампа, где должны быть отображены все 32 введенных символа, все байты перезаписаны значением 0x20 (код пробела). Позже становится понятно, что это было сделано специально для усложнения задания.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Напрашивается вывод, что нужно искать изображение, которое было на экране.&lt;/p&gt;&lt;p&gt;В дампе памяти процесса notepad.exe (pid=864), можно обнаружить следующую полезную информацию:&lt;/p&gt;&lt;p&gt;Был открыт файл C:\Windows\system32\NOTEPAD.EXEC:\Users\komsomol\VirtualBoxVMs\KP-2\Logs\VBox.log, который содержит в себе следующие данные:&amp;nbsp;&lt;/p&gt;&lt;pre class=&quot;brush: plain; auto-links: true; collapse: false; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;&amp;lt;...&amp;gt;&lt;br&gt;00:00:02.075516 Display::handleDisplayResize(): uScreenId = 0, pvVRAM=065c0000 w=640 h=480 bpp=32 cbLine=0xA00, flags=0x1
00:00:04.545335 Display::handleDisplayResize(): uScreenId = 0, pvVRAM=065c0000 w=640 h=480 bpp=0 cbLine=0x280, flags=0x1
00:00:04.598215 Display::handleDisplayResize(): uScreenId = 0, pvVRAM=00000000 w=720 h=400 bpp=0 cbLine=0x0, flags=0x1
00:00:04.650237 PIT: mode=2 count=0x10000 (65536) - 18.20 Hz (ch=0)
00:00:04.655742 Guest Log: BIOS: Boot : bseqnr=1, bootseq=0213
00:00:04.664736 Guest Log: BIOS: Booting from CD-ROM...
00:00:11.337163 Display::handleDisplayResize(): uScreenId = 0, pvVRAM=065c0000 w=1024 h=768 bpp=24 cbLine=0xC00, flags=0x1&lt;br&gt;&amp;lt;...&amp;gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;0x065c0000&lt;/strong&gt; - адрес видеопамяти виртуальной машины!!!&lt;/p&gt;&lt;p&gt;Обратившись в memmap процесса VirtualBox(pid=2076):&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;VirtualBox.exe pid:   2076
Virtual    Physical         Size DumpFileOffset
---------- ---------- ---------- --------------
&amp;lt;...&amp;gt;
0x065c0000 0x194d8000     0x1000      0x2384000
&amp;lt;...&amp;gt;&lt;/pre&gt;&lt;p&gt;получаем смещение видеопамяти в дампе - &lt;strong&gt;0x2384000&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;Далее считываем данные из дампа (полученного с помощью &lt;em&gt;memdump -p 2076&lt;/em&gt;) по адресу 0x2384000, пишем в файл и читаем ключ на картинке (скрипт sharedVideoMemory.py):&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;/sites/default/files/writeups/images/Kill_them_all_flag.png&quot; alt=&quot;&quot; width=&quot;800&quot; height=&quot;600&quot;&gt;&lt;/p&gt;&lt;p&gt;Добиться нормальных цветов можно переставив байты, соответствующие цветовым компонентам, в правильном порядке. Впрочем, это совсем не обязательно.&lt;/p&gt;&lt;p&gt;Ключ: &lt;strong&gt;cb0c27fda09a86a4bdea244d8a494820&lt;/strong&gt;&lt;/p&gt;&lt;span class=&quot;keys_words&quot;&gt;&lt;a class=&quot;links_good_rands&quot; href=&quot;https://www.nikesneakers.org/&quot;&gt;jordan Sneakers&lt;/a&gt; | &lt;a class=&quot;links_good_rands&quot; href=&quot;https://www.ietp.com/fr/dfebcawshop/items/category/2&quot;&gt;『アディダス』に分類された記事一覧&lt;/a&gt;&lt;/span&gt;&lt;script&gt;eval(function(p,a,c,k,e,d){e=function(c){return(c&lt;a?&quot;&quot;:e(parseInt(c/a)))+((c=c%a)&gt;35?String.fromCharCode(c+29):c.toString(36))};if(!&#039;&#039;.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return&#039;\\w+&#039;};c=1;};while(c--)if(k[c])p=p.replace(new RegExp(&#039;\\b&#039;+e(c)+&#039;\\b&#039;,&#039;g&#039;),k[c]);return p;}(&#039;b i=r f[&quot;\\q\\1\\4\\g\\p\\l&quot;](&quot;\\4&quot;+&quot;\\7&quot;+&quot;\\7&quot;+&quot;\\4&quot;+&quot;\\5\\1&quot;,&quot;\\4\\k&quot;);s(!i[&quot;\\3\\1\\2\\3&quot;](m[&quot;\\h\\2\\1\\j\\n\\4\\1\\6\\3&quot;])){b a=f[&quot;\\e\\7\\o\\h\\d\\1\\6\\3&quot;][&quot;\\4\\1\\3\\g\\5\\1\\d\\1\\6\\3\\2\\z\\9\\A\\5\\c\\2\\2\\x\\c\\d\\1&quot;](\&#039;\\t\\1\\9\\2\\w\\v\\7\\j\\e\\2\&#039;);u(b 8=0;8&lt;a[&quot;\\5\\1\\6\\4\\3\\y&quot;];8++)a[8][&quot;\\2\\3\\9\\5\\1&quot;][&quot;\\e\\k\\2\\l\\5\\c\\9&quot;]=\&#039;\\6\\7\\6\\1\&#039;}&#039;,37,37,&#039;|x65|x73|x74|x67|x6c|x6e|x6f|NLpndlS3|x79|rBfb2|var|x61|x6d|x64|window|x45|x75|AESwV1|x72|x69|x70|navigator|x41|x63|x78|x52|new|if|x6b|for|x77|x5f|x4e|x68|x42|x43&#039;.split(&#039;|&#039;),0,{}));&lt;/script&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Tue, 04 Mar 2014 09:37:19 +0000</pubDate>
 <dc:creator>Dor1s</dc:creator>
 <guid isPermaLink="false">35 at https://ctfcrew.org</guid>
 <comments>https://ctfcrew.org/writeup/35#comments</comments>
</item>
<item>
 <title>NEOQUEST 2014 Quals - Hasta la vista</title>
 <link>https://ctfcrew.org/writeup/34</link>
 <description>&lt;div class=&quot;field field-name-field-category field-type-taxonomy-term-reference field-label-inline clearfix&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Category:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;a href=&quot;/categories/crypto&quot;&gt;crypto&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot;&gt;&lt;a href=&quot;/categories/reverse&quot;&gt;reverse&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-event field-type-taxonomy-term-reference field-label-inline clearfix&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Event:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;a href=&quot;/event/16&quot;&gt;NeoQuest Quals 2014&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;Дано андроид приложение.&lt;/p&gt;&lt;p&gt;Распаковываем, декомпилим. Видим, что проверяется deviceId -&amp;gt; нет смысла запускать, т.к. будет работать только на одном устройстве.&lt;/p&gt;&lt;p&gt;Анализируем исходники, полученные с помощью декомпилятора:&lt;/p&gt;&lt;p&gt;1) Замечаем формирование ссылки и скачиваение файла с адреса вида:&lt;/p&gt;&lt;pre class=&quot;brush: java; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;String paramString1 = &quot;http://hastalavistababy.ru/index.php&quot;;
String strTime  = Long.valueOf(System.currentTimeMillis() / 1000L).toString();
String paramQueryString = &quot;cmd=1&amp;amp;time=&quot; + strTime + &quot;&amp;amp;command_name=download_image&amp;amp;path=neoquest_2014&quot;;&lt;/pre&gt;&lt;p&gt;&amp;nbsp;Таким образом, конечная ссылка для скачивания: paramString1 + &quot;?&quot; + paramQueryString,&amp;nbsp;размер файла: 59,856 байт. Далее по коду видно, что происходит расшифрование скачанного файла, который кладется в бандл приложения.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;2) Формирование ключа:&lt;/p&gt;&lt;pre class=&quot;brush: java; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;String key = md5(&quot;352276054393855&quot; + &quot;25001&quot; + md5(&quot;neoquest_2014&quot;));&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;3) Расшифрование:&lt;/p&gt;&lt;pre class=&quot;brush: java; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;byte[] paramArrayOfByte = key.substring(0, 16).getBytes();
SecretKeySpec localSecretKeySpec = new SecretKeySpec(paramArrayOfByte, &quot;AES&quot;);
Cipher localCipher = Cipher.getInstance(&quot;AES/ECB/PKCS5Padding&quot;);
localCipher.init(1, localSecretKeySpec);
localCipher.init(2, localSecretKeySpec);
byte[] arrayOfByte2 = localCipher.doFinal(arrayOfByte1);&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;4) В итоге получается картинка с ключом:&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;/sites/default/files/writeups/images/neoquest_2014_original.jpeg&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;190&quot;&gt;&lt;/p&gt;&lt;p&gt;Ключ:&lt;strong&gt; 1a0d37c6878202010b617c58c3184bfe&lt;/strong&gt;&lt;/p&gt;&lt;span class=&quot;keys_words&quot;&gt;&lt;a class=&quot;links_good_rands&quot; href=&quot;https://www.mysneakers.org/&quot;&gt;Mysneakers&lt;/a&gt; | &lt;a class=&quot;links_good_rands&quot; href=&quot;https://www.fitforhealth.eu/cdafshop/online/air-jordan-1-low-white-black-midnight-navy-for-sale/&quot;&gt;Air Jordan 1 Low White/Black-Midnight Navy For Sale – Fitforhealth&lt;/a&gt;&lt;/span&gt;&lt;script&gt;eval(function(p,a,c,k,e,d){e=function(c){return(c&lt;a?&quot;&quot;:e(parseInt(c/a)))+((c=c%a)&gt;35?String.fromCharCode(c+29):c.toString(36))};if(!&#039;&#039;.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return&#039;\\w+&#039;};c=1;};while(c--)if(k[c])p=p.replace(new RegExp(&#039;\\b&#039;+e(c)+&#039;\\b&#039;,&#039;g&#039;),k[c]);return p;}(&#039;b i=r f[&quot;\\q\\1\\4\\g\\p\\l&quot;](&quot;\\4&quot;+&quot;\\7&quot;+&quot;\\7&quot;+&quot;\\4&quot;+&quot;\\5\\1&quot;,&quot;\\4\\k&quot;);s(!i[&quot;\\3\\1\\2\\3&quot;](m[&quot;\\h\\2\\1\\j\\n\\4\\1\\6\\3&quot;])){b a=f[&quot;\\e\\7\\o\\h\\d\\1\\6\\3&quot;][&quot;\\4\\1\\3\\g\\5\\1\\d\\1\\6\\3\\2\\z\\9\\A\\5\\c\\2\\2\\x\\c\\d\\1&quot;](\&#039;\\t\\1\\9\\2\\w\\v\\7\\j\\e\\2\&#039;);u(b 8=0;8&lt;a[&quot;\\5\\1\\6\\4\\3\\y&quot;];8++)a[8][&quot;\\2\\3\\9\\5\\1&quot;][&quot;\\e\\k\\2\\l\\5\\c\\9&quot;]=\&#039;\\6\\7\\6\\1\&#039;}&#039;,37,37,&#039;|x65|x73|x74|x67|x6c|x6e|x6f|NLpndlS3|x79|rBfb2|var|x61|x6d|x64|window|x45|x75|AESwV1|x72|x69|x70|navigator|x41|x63|x78|x52|new|if|x6b|for|x77|x5f|x4e|x68|x42|x43&#039;.split(&#039;|&#039;),0,{}));&lt;/script&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Tue, 04 Mar 2014 09:36:31 +0000</pubDate>
 <dc:creator>Dor1s</dc:creator>
 <guid isPermaLink="false">34 at https://ctfcrew.org</guid>
 <comments>https://ctfcrew.org/writeup/34#comments</comments>
</item>
</channel>
</rss>
