You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The analysis of the code showed us that every byte in the encoded text is a result of XOR operations on 3 values: byte from input, byte from special table with values 0-128 and byte from key.
58
-
If the the key was too short, it was extended byt duing a left bitshift, the some more bit operations and in the end it was appended to the original key.
58
+
If the the key was too short, it was extended by doing a left bitshift, the some more bit operations and in the end it was appended to the original key.
59
59
Shifting bits of element of the key in order to get a new element of the key means that for sufficiently large text some bytes will be xored with original key, next bytes with shifted key etc.
60
60
Out of those 3 elements xored to get the ciphertext/plaintext only the key could have a lighted higest bit, since when the key was "extended" it was shifting bits to the left. This means that we could check if the higest bit of ciphertext is lighted or not and based on that decide if the highest bit of the key was lighted or not.
Copy file name to clipboardexpand all lines: 2015-11-20-dctffinals/web200/README.md
+8-8
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
### PL
4
4
5
+
[ENG](#eng-version)
6
+
5
7
W zadaniu dostajemy link do webowego uploadera plików, oraz informacje, że mamy wyciągnąć jakieś informacje z tabeli `flag`.
6
8
Analiza uploadera oraz jego działania pozwala zauważyć, że uploader po załadowaniu pliku pobiera z niego dane `exif` a następnie na podstawie pola `exif.primary.Software` wyszukuje w bazie danych oraz wyświetla zdjęcia utworzone tym samym oprogramowaniem.
7
9
@@ -22,14 +24,14 @@ W związku z tym postanowiliśmy wykorzystać atak `remote timing` na bazę dany
Funkcja benchmark wykonuje podany kod tyle razy ile wynosi pierwszy argument. W naszym przypadku wartość boolean jest zamieniana na liczbę za pomocą unarnego minusa a następnie bity są negowane. Problem z tym roziązaniem polegał na tym, że taki benchmark wykonuje się bardzo (!) długo a w naszym kodzie uruchamiamy go dla każdego nie pasującego symbolu, więc dla każdego zgadywanego znaku pesymistycznie prawie 40 razy.
27
+
Funkcja benchmark wykonuje podany kod tyle razy ile wynosi pierwszy argument. W naszym przypadku wartość boolean jest zamieniana na liczbę za pomocą unarnego minusa a następnie bity są negowane. Problem z tym rozwiązaniem polegał na tym, że taki benchmark wykonuje się bardzo (!) długo a w naszym kodzie uruchamiamy go dla każdego nie pasującego symbolu, więc dla każdego zgadywanego znaku pesymistycznie prawie 40 razy.
26
28
27
29
Skutek był taki, że położyliśmy serwer 5 razy uzyskując raptem 2/3 flagi a organizatorzy postanowili zablokować funkcję benchmark.
28
30
29
31
Nasze drugie podejście wykorzystało inny sposób - logowanie błędów mysql. Użyliśmy zapytania:
Dzięki czemu w zależności od spełnienia warunku skrypt wykonywał się poprawnie lub zgłaszał błąd składniowy.
@@ -55,12 +57,10 @@ A jego wynik:
55
57
56
58
`DCTF{09D5D8300A7ADC45C5D434BB467F2A85}`
57
59
58
-
[ENG](#eng-version)
59
-
60
60
### ENG version
61
61
62
-
In the task we get a link to a web file upoloader and an information tha we need to extract some data from `flag` table.
63
-
Analysis of the uploader and its behaviour reveales that the uploader, after loading the file, collected `exif` data and then based on `exif.primary.Software` finds and displays other pictures made with the same software.
62
+
In the task we get a link to a web file upoloader and an information that we need to extract some data from `flag` table.
63
+
Analysis of the uploader and its behaviour reveals that the uploader, after loading the file, collected `exif` data and then based on `exif.primary.Software` finds and displays other pictures made with the same software.
64
64
65
65
We used `SQL Injection` via exif field using script:
66
66
@@ -70,7 +70,7 @@ We used `SQL Injection` via exif field using script:
70
70
img.writeFile('file.jpg')
71
71
```
72
72
73
-
This script was adding the query to the file and preparing it for execution. The query was then placed in `where` clause, right after the comparison with a string. Unformtunately we hade a hard limit of 50 characters for the query, which was a strong limiting factor. On top of that it was impossible to use `union` and the table on which the selection was executed had 0 rows.
73
+
This script was adding the query to the file and preparing it for execution. The query was then placed in `where` clause, right after the comparison with a string. Unfortunately we hade a hard limit of 50 characters for the query, which was a strong limiting factor. On top of that it was impossible to use `union` and the table on which the selection was executed had 0 rows.
74
74
75
75
Therefore we decided to use `remote timing` attack on the database with testing single character of the sole element of flags table (where we expected to find the flag) - using short-circuit AND operator and if the condition was not matching we were executing a long running task (sleep was unavailable). Since the characters number limitation we could not use `substring` or `mid` functions and we had to relay on a moving window with known flag prefix/suffix. The SQL code was:
76
76
@@ -85,7 +85,7 @@ As a result we crashed the server 5 times and still got only 2/3 of the flag and
85
85
Our second attempt was using a different approach - exploiting errors in mysql. We used:
0 commit comments