# DrWeb 2023

## 1: 100 Simple .exe

Mục đích của bài này là decompyle file exe sang py sử dụng py2exe hoặc có thể uncompyle6.

Sử dụng decompile-py2exe: <https://github.com/NVISOsecurity/decompile-py2exe>

Cách cài đặt uncompyle6: <https://palomarinfosec.github.io/Presentations/InstallingUncompyle6.pdf>

Cách cài đặt python3.9:

<figure><img src="/files/EOJj2JXdwyenzl8hqK8J" alt=""><figcaption></figcaption></figure>

Cài đặt pip 2.7

```python
wget -P ~/.local/lib https://bootstrap.pypa.io/pip/2.7/get-pip.py
python2.7 ~/.local/lib/get-pip.py --user 
#if using bash
printf "\nPATH=\$PATH:~/.local/bin/" >> ~/.bashrc
source ~/.bashrc
```

## 2: 100 Tools -> Repair

Đối với bài này thì họ mô tả liên quan đến định dạng của file. Tải về là file dạng `what.rar`

<figure><img src="/files/PFrfBO7BKw79tq1J8oTs" alt=""><figcaption></figcaption></figure>

Tuy nhiên giải nén file rar này thì không được vì thấy báo là lỗi định dạng. Ta vào kiểm tra mã hex của nó:&#x20;

<figure><img src="/files/esQO1G77Fiz0Hxba3j3B" alt=""><figcaption></figcaption></figure>

Nhận thấy signature file của nó là `50 4B 03 04` là file zip -> đổi lại định dạng file thì nó vẫn thấy báo lỗi khi tôi giải nén.&#x20;

<figure><img src="/files/WVCqIMd6Kftu3WE785lZ" alt=""><figcaption></figcaption></figure>

Vâng báo lỗi liên quan đến PADDING mà tôi kiếm trên mạng không thấy là gì.? Sau đó tôi tạo ra 1 file zip khác để kiểm tra xem định dạng chuẩn của nó là gì:&#x20;

<figure><img src="/files/sMtXANH4IKC18c9GyYkC" alt=""><figcaption></figcaption></figure>

Nhận thấy sau 4 bytes đầu của file mới tạo là 00 00 00 08 00 mà file bài cho cũng có nhưng lại sau đoạn PADDING -> tôi hiểu là bài chèn thêm vào để mình không thể giải nén được nó -> tôi xóa đi và giải nén -> Nhận được file flag.exe

<figure><img src="/files/Xn7cv6qS9nEMGIYxVbzs" alt=""><figcaption></figcaption></figure>

Chạy chương trình ta nhận được kết quả là flag:

<figure><img src="/files/0n0ejKiAYecl8vuAzYNc" alt=""><figcaption></figcaption></figure>

## 3: 100 Supreme paycheck

Đối với bài này sử dụng macro trong file docm, một dạng nguy hiểm chèn các đoạn code mã độc ẩn giấu, nếu không để ý chúng ta có thể trở thành nạn nhân của loại này.

Bài ta nhận được là file `document.docm`, để trích xuất đoạn macro này ra thì ta có nhiều tools để sử dụng, nhưng tôi sử dụng được tools `oledump.py`(link tải: <https://blog.didierstevens.com/programs/oledump-py/>):

<figure><img src="/files/u7DPtKkQ15jRC6k6jQSV" alt=""><figcaption></figcaption></figure>

Ta nhận được file .bin chứa macro gồm có 6 phần. Kiểm tra xem nội dung của các phần là gì ta sử dụng câu lệnh:

<figure><img src="/files/UmwzQvDrVsxfHBxuB7Wq" alt=""><figcaption></figcaption></figure>

Và ta nhận được phần cần quan tâm là:

<figure><img src="/files/j6djtR3wYYs0yCcjwint" alt=""><figcaption></figcaption></figure>

Ta chuyển nội dung nhận được qua file sample.vbs ta nhận:

<figure><img src="/files/ITGTKud3etCv2u9S5Ty6" alt=""><figcaption></figcaption></figure>

Đoạn trên đó là VBScript Obfuscator. Để giải mã nó có thể sử dụng tool ở link: <https://isvbscriptdead.com/vbs-obfuscator/>. Hoặc có thể thay đổi Execute thành Msgbox, rồi run đoạn đó thì ta sẽ nhận được đoạn code đọc hiểu dễ hơn như ngôn ngữ bậc cao:

<figure><img src="/files/ye4VctiOXCCVpdW3c6bL" alt=""><figcaption></figcaption></figure>

Từ đây ta dễ dàng nhận được flag của bài này là gì>>

## 4: 200 Supreme victory

Bài này ta nhận được file dạng pdf. ( [1. Basic Struture of PDF](/home/education/other/1.-basic-struture-of-pdf.md))

Ta kiểm tra trailer thì thấy `/Root` là object `1 0 R` và `/Info 13 0 R`&#x20;

<figure><img src="/files/OpWz2EvRIP8smHKHX74Z" alt=""><figcaption></figcaption></figure>

Nội dung của đối tượng 13 tên khá quen thuộc

<figure><img src="/files/PwVYbv37rMeGjcWilSHk" alt=""><figcaption></figcaption></figure>

và phần `1 0 R` nhận được:

<figure><img src="/files/ConNqkjl98Obj6bPA2lw" alt=""><figcaption></figcaption></figure>

Khi đối tượng đầu tiên được chạy thì thấy có hành động đáng ngờ của /OpenAction 15 0 R ngay lập tức hiển thị:

<figure><img src="/files/Hyrds2fHFIb8tzI2HpCw" alt=""><figcaption></figcaption></figure>

Vâng nội dung phần này là đoạn code JS đã được obfuscate (xáo trộn). Đầy tiên tôi nhận thích các dấu đóng ngoặc và mở ngoặc tròn đều có dầu gạch chéo trước -> tôi xóa nó đi nhận được đoạn code mới:

```javascript
function _0xa35c() {
    const _0x1c44de = ['WQHiW4JcJ8k/', 'mtCZnZi0mdbRzMPnvvO', 'meZdLg3dMgHwr8osW5pcGSkl', '4392640jOAQvD', 'hmoYWPdcGW', '6590826eUWCBo', 'x8oaWPWKteTDW4zyt8o1WOn6xW', 'WRPuW4hcLmk/', 'kekXgrepmDRW_2007_5PDFrGePDFDRWmGePDFrx', 'WQ3cVdldR0ruWPSMWQZdPCk5W4RdKG', 'push', 'rhjxzwi', 'CMvWBgfJzq', 'yGZcIcq', 'WPRcH2C', 'WPW5WOLaC8osWQG', 'y2HHCKnVzgvbDa', 'W4TdWPWaWPjdW7JcISorW7jc', '639807NekrWM', 'F8onrCkVW515oYddPITI', 'WQzvWOBdKeu4WP8', 'mZa1uNfUExft', 'nti5otC3qu5WCNfQ', 'W5dcTfNcVCkFWQy', '1929204ZhjfyE', 'replace', 'yWZcGJNcRdD2E8oHW47cL8ke', 'AM9PBG', 'DgvZDa', 's8kRW4/dGq'];
    _0xa35c = function () {
        return _0x1c44de;
    };
    return _0xa35c();
}
const _0xb060c5 = _0x1481, _0x4ee7d2 = _0x456e, _0x4e6538 = _0x21e7;
(function (_0x375ed7, _0x1e0a72) {
    const _0x4944e1 = _0x456e,
        _0x4da4a8 = _0x1481,
        _0x17ac9d = _0x21e7,
        _0x4f8fa5 = _0x375ed7();
    while (!![]) {
        try {
            const _0x1bea46 = parseInt(_0x17ac9d(0x191)) / 0x1 + parseInt(_0x4da4a8(0x188, ']Jc!')) / 0x2 + parseInt(_0x4da4a8(0x181, '$7Id')) / 0x3 + -parseInt(_0x4da4a8(0x190, 'bvkP')) / 0x4 * (-parseInt(_0x4944e1(0x176)) / 0x5) + parseInt(_0x17ac9d(0x184)) / 0x6 + -parseInt(_0x17ac9d(0x182)) / 0x7 + -parseInt(_0x4944e1(0x180)) / 0x8;
            if (_0x1bea46 === _0x1e0a72) break;
            else _0x4f8fa5['push'](_0x4f8fa5['shift']());
        } catch (_0x344005) {
            _0x4f8fa5['push'](_0x4f8fa5['shift']());
        }
    }
}(_0xa35c, 0xaa042));

function _0x21e7(_0x310d38, _0x4790e6) {
    const _0xa35cf2 = _0xa35c();
    return _0x21e7 = function (_0x21e7d0, _0x4f5d40) {
        _0x21e7d0 = _0x21e7d0 - 0x175;
        let _0x5753e0 = _0xa35cf2[_0x21e7d0];
        return _0x5753e0;
    }, _0x21e7(_0x310d38, _0x4790e6);
}
const alphabetShift = _0x36f924 => {
    const _0x2602ec = _0x21e7,
        _0x40db2c = _0x456e,
        _0x4b74e6 = _0x1481;
    let _0x13fd36 = _0x36f924[_0x4b74e6(0x17f, 'Ul*r')]('');
    const _0x553b97 = _0x13fd36[_0x4b74e6(0x178, 'o39D')];
    let _0x13d867 = [];
    for (let _0x6193d2 = 0x0; _0x6193d2 < _0x553b97; _0x6193d2++) {
        if (/^[a-yA-Y1-8]+$/[_0x40db2c(0x17d)](_0x13fd36[_0x6193d2])) {
            let _0x358052 = String[_0x4b74e6(0x17b, '$7Id')](_0x13fd36[_0x6193d2][_0x40db2c(0x18f)](0x0) + 0x5);
            _0x13d867[_0x2602ec(0x189)](_0x4b74e6(0x17e, 'j46W')['includes'](_0x358052) ? _0x358052['toUpperCase']() : _0x358052);
        } else /^[zZ]+$/[_0x40db2c(0x17d)](_0x13fd36[_0x6193d2]) ? _0x13d867[_0x2602ec(0x189)]('A') : _0x13d867['push'](_0x13fd36[_0x6193d2]);
    }
    return _0x13d867[_0x40db2c(0x17c)]('');
};

function _0x456e(_0x310d38, _0x4790e6) {
    const _0xa35cf2 = _0xa35c();
    return _0x456e = function (_0x21e7d0, _0x4f5d40) {
        _0x21e7d0 = _0x21e7d0 - 0x175;
        let _0x5753e0 = _0xa35cf2[_0x21e7d0];
        if (_0x456e['yElyAM'] === undefined) {
            var _0x140c17 = function (_0x14810d) {
                const _0x4ccc54 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';
                let _0x380d74 = '',
                    _0x51b148 = '';
                for (let _0x56dfd1 = 0x0, _0x4674c2, _0x1f18d7, _0x456eab = 0x0; _0x1f18d7 = _0x14810d['charAt'](_0x456eab++); ~_0x1f18d7 && (_0x4674c2 = _0x56dfd1 % 0x4 ? _0x4674c2 * 0x40 + _0x1f18d7 : _0x1f18d7, _0x56dfd1++ % 0x4) ? _0x380d74 += String['fromCharCode'](0xff & _0x4674c2 >> (-0x2 * _0x56dfd1 & 0x6)) : 0x0) {
                    _0x1f18d7 = _0x4ccc54['indexOf'](_0x1f18d7);
                }
                for (let _0x5e2c91 = 0x0, _0x38d6c6 = _0x380d74['length']; _0x5e2c91 < _0x38d6c6; _0x5e2c91++) {
                    _0x51b148 += '%' + ('00' + _0x380d74['charCodeAt'](_0x5e2c91)['toString'](0x10))['slice'](-0x2);
                }
                return decodeURIComponent(_0x51b148);
            };
            _0x456e['ZLQVwH'] = _0x140c17, _0x310d38 = arguments, _0x456e['yElyAM'] = !![];
        }
        const _0x2fe2ed = _0xa35cf2[0x0],
            _0x87220b = _0x21e7d0 + _0x2fe2ed,
            _0x3d875c = _0x310d38[_0x87220b];
        return !_0x3d875c ? (_0x5753e0 = _0x456e['ZLQVwH'](_0x5753e0), _0x310d38[_0x87220b] = _0x5753e0) : _0x5753e0 = _0x3d875c, _0x5753e0;
    }, _0x456e(_0x310d38, _0x4790e6);
}

function _0x1481(_0x310d38, _0x4790e6) {
    const _0xa35cf2 = _0xa35c();
    return _0x1481 = function (_0x21e7d0, _0x4f5d40) {
        _0x21e7d0 = _0x21e7d0 - 0x175;
        let _0x5753e0 = _0xa35cf2[_0x21e7d0];
        if (_0x1481['OQCRVp'] === undefined) {
            var _0x140c17 = function (_0x4ccc54) {
                const _0x380d74 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';
                let _0x51b148 = '',
                    _0x56dfd1 = '';
                for (let _0x4674c2 = 0x0, _0x1f18d7, _0x456eab, _0x5e2c91 = 0x0; _0x456eab = _0x4ccc54['charAt'](_0x5e2c91++); ~_0x456eab && (_0x1f18d7 = _0x4674c2 % 0x4 ? _0x1f18d7 * 0x40 + _0x456eab : _0x456eab, _0x4674c2++ % 0x4) ? _0x51b148 += String['fromCharCode'](0xff & _0x1f18d7 >> (-0x2 * _0x4674c2 & 0x6)) : 0x0) {
                    _0x456eab = _0x380d74['indexOf'](_0x456eab);
                }
                for (let _0x38d6c6 = 0x0, _0x43c43d = _0x51b148['length']; _0x38d6c6 < _0x43c43d; _0x38d6c6++) {
                    _0x56dfd1 += '%' + ('00' + _0x51b148['charCodeAt'](_0x38d6c6)['toString'](0x10))['slice'](-0x2);
                }
                return decodeURIComponent(_0x56dfd1);
            };
            const _0x14810d = function (_0x2db6f9, _0x2995b5) {
                let _0x49df1c = [],
                    _0x36f924 = 0x0,
                    _0x13fd36, _0x553b97 = '';
                _0x2db6f9 = _0x140c17(_0x2db6f9);
                let _0x13d867;
                for (_0x13d867 = 0x0; _0x13d867 < 0x100; _0x13d867++) {
                    _0x49df1c[_0x13d867] = _0x13d867;
                }
                for (_0x13d867 = 0x0; _0x13d867 < 0x100; _0x13d867++) {
                    _0x36f924 = (_0x36f924 + _0x49df1c[_0x13d867] + _0x2995b5['charCodeAt'](_0x13d867 % _0x2995b5['length'])) % 0x100, _0x13fd36 = _0x49df1c[_0x13d867], _0x49df1c[_0x13d867] = _0x49df1c[_0x36f924], _0x49df1c[_0x36f924] = _0x13fd36;
                }
                _0x13d867 = 0x0, _0x36f924 = 0x0;
                for (let _0x6193d2 = 0x0; _0x6193d2 < _0x2db6f9['length']; _0x6193d2++) {
                    _0x13d867 = (_0x13d867 + 0x1) % 0x100, _0x36f924 = (_0x36f924 + _0x49df1c[_0x13d867]) % 0x100, _0x13fd36 = _0x49df1c[_0x13d867], _0x49df1c[_0x13d867] = _0x49df1c[_0x36f924], _0x49df1c[_0x36f924] = _0x13fd36, _0x553b97 += String['fromCharCode'](_0x2db6f9['charCodeAt'](_0x6193d2) ^ _0x49df1c[(_0x49df1c[_0x13d867] + _0x49df1c[_0x36f924]) % 0x100]);
                }
                return _0x553b97;
            };
            _0x1481['oKNagW'] = _0x14810d, _0x310d38 = arguments, _0x1481['OQCRVp'] = !![];
        }
        const _0x2fe2ed = _0xa35cf2[0x0],
            _0x87220b = _0x21e7d0 + _0x2fe2ed,
            _0x3d875c = _0x310d38[_0x87220b];
        return !_0x3d875c ? (_0x1481['CmdQwO'] === undefined && (_0x1481['CmdQwO'] = !![]), _0x5753e0 = _0x1481['oKNagW'](_0x5753e0, _0x4f5d40), _0x310d38[_0x87220b] = _0x5753e0) : _0x5753e0 = _0x3d875c, _0x5753e0;
    }, _0x1481(_0x310d38, _0x4790e6);
}
var text = _0x4e6538(0x187); text = text[_0x4ee7d2(0x18b)](/PDF/g, '7'), text = text[_0x4e6538(0x17a)](/DRW/g, '4'), text = text[_0x4e6538(0x17a)](/Ge7/g, '3'), text = text[_0x4ee7d2(0x18b)](_0xb060c5(0x18c, '$7Id'), '1'), text = text[_0xb060c5(0x18e, 'q]^9')]('X', '{'), text = text[_0xb060c5(0x175, 'aTYz')]('x', '}'), text = text[_0x4ee7d2(0x18b)]('kek', _0x4ee7d2(0x18a)), text = text['replace'](_0xb060c5(0x183, 'j46W'), _0xb060c5(0x18d, '$scN')), app[_0xb060c5(0x186, 'Ul*r')](alphabetShift(text), 0x3);
```

Sau đó nén nó vào deobfuscate ở web: <https://deobfuscate.relative.im/> ta nhận được đoạn code:

```javascript
const alphabetShift = (_0x36f924) => {
  let _0x13fd36 = _0x36f924.split('')
  const _0x553b97 = _0x13fd36.length
  let _0x13d867 = []
  for (let _0x6193d2 = 0; _0x6193d2 < _0x553b97; _0x6193d2++) {
    if (/^[a-yA-Y1-8]+$/.test(_0x13fd36[_0x6193d2])) {
      let _0x358052 = String.fromCharCode(
        _0x13fd36[_0x6193d2].charCodeAt(0) + 5
      )
      _0x13d867.push(
        'eiou'.includes(_0x358052) ? _0x358052.toUpperCase() : _0x358052
      )
    } else {
      ;/^[zZ]+$/.test(_0x13fd36[_0x6193d2])
        ? _0x13d867.push('A')
        : _0x13d867.push(_0x13fd36[_0x6193d2])
    }
  }
  return _0x13d867.join('')
}
var text = 'kekXgrepmDRW_2007_5PDFrGePDFDRWmGePDFrx'
text = text.replace(/PDF/g, '7')
text = text.replace(/DRW/g, '4')
text = text.replace(/Ge7/g, '3')
text = text.replace('grep', '1')
text = text.replace('X', '{')
text = text.replace('x', '}')
text = text.replace('kek', 'DrWeb')
text = text.replace('2007', 'Pdf')
app.alert(alphabetShift(text), 3)
```

Vâng dễ dàng nhận thấy biến text kia sẽ thực hiện một số câu lệnh rồi thông báo cho mình đoạn text sau cùng đó. Vậy chắc chắn đó là flag rồi. (<https://runjs.co/s/$wpGKN5mJ>)

<figure><img src="/files/4FUdOqdnRX1pizv6holK" alt=""><figcaption></figcaption></figure>

## 5: 200 De-DoS me

Như tiêu đề đã phần nào gợi ý cho chúng ta thì ta mở file xem mã hex:

<figure><img src="/files/sAmWyfIOhIHKm9WILYHi" alt=""><figcaption></figcaption></figure>

Vâng phần DOS-MS đã bị thay đổi và ta sẽ sử dụng phần mềm DOSBox (<https://www.dosbox.com/download.php?main=1>) kéo file đó vào để mở tạ nhận được:

<figure><img src="/files/KqN8GfgiiEB8Sh0XdZfA" alt=""><figcaption></figcaption></figure>

Sau đó tôi không biết làm gì vì tôi mới sài phần mềm này lần đầu, rồi tôi kiểm tra xem đang ở vị trí vào và gồm những file nào rồi thì tôi nhận được flag:

<figure><img src="/files/XnvaVm5AyO9vtQXhZLZm" alt=""><figcaption></figcaption></figure>

## 6: 200 Ping

Kiểm tra nội dung ta nhận được:

<figure><img src="/files/0KsrM62S6Bqi5dOHu8BB" alt=""><figcaption></figcaption></figure>

Reverse Godot: <https://github.com/bruvzg/gdsdecomp> -> mở phần mềm và giải nén file ra ta nhận được 1 thư mục gồm nhiều file:

<figure><img src="/files/8GCfjJKevzkzuRWOcfUp" alt=""><figcaption></figcaption></figure>

Kiểm tra qua ta nhận được nội dung của 1 file trong thư mục nhận được là:

```
extends Area2D

const DEFAULT_SPEED = 200

var direction = Vector2.LEFT

onready var _initial_pos = position
onready var _speed = DEFAULT_SPEED

func _process(delta):
	_speed += delta * 2
	position += _speed * delta * direction


func reset():
	direction = Vector2.LEFT
	position = _initial_pos
	_speed = DEFAULT_SPEED


func flag():
	var flag_bin = [68, 114, 87, 101, 98, 123, 80, 
						49, 110, 54, 95, 77, 51, 95, 
						80, 48, 110, 54, 95, 77, 51, 
						125]
	var flag = ""
	for i in range(0, flag_bin.size()):
		flag = flag + char(flag_bin[i])
	print_debug(flag)

```

Vầng lưu ý của bài này là nhớ tải về phiên bản phù hợp để nhận được file mở rộng .gd để nhận được nội dung dễ đọc nhé.

## 7: 200 Back to the Future

Đối với bài này ta có lưu ý:

* `struct tm` là một cấu trúc trong ngôn ngữ lập trình C được sử dụng để biểu diễn thông tin về thời gian và ngày tháng <`time.h`> . Có một điểm lưu ý là giá trị năm được tính từ năm 1900.<br>

  <figure><img src="/files/6DHbHC36DeS8ntukSOYS" alt=""><figcaption></figcaption></figure>
* Để chuyển từ dạng cấu trúc `struct tm` sang dạng số giây, thì ta sử dụng hàm `mktime()` được định nghĩa trong hàm thư viện `time.h`. Hàm nhận đối số là con trỏ `struct tm` và trả về số giây kể từ Epoch (1/1/1970)
* Ví dụ:

```c
#include <stdio.h>
#include <time.h>

int main() {
    struct tm timeinfo;
    timeinfo.tm_year = 2023 - 1900; // Năm 2023
    timeinfo.tm_mon = 11; // Tháng 12
    timeinfo.tm_mday = 28; // Ngày 28

    time_t seconds = mktime(&timeinfo);

    printf("Số giây kể từ Epoch: %ld\n", seconds);

    return 0;
}
```

* Hoặc có thể sử dụng link này để tính thời gian bằng giây: <https://www.epochconverter.com/>

Vậy là cơ bản bài này là vậy, điểm lại một chút:

<figure><img src="/files/xRfOXlwEU1gGqRBt080q" alt=""><figcaption></figcaption></figure>

Đây là thời gian time theo cấu trúc tm. Kiểm tra arg1 của mình truyền vào và kiểm tra xem thời gian hiện tại có là thời gian như trên không. Tiếp theo sẽ vào hàm `sub_401256()` để kiểm tra.

<figure><img src="/files/2dOJYlstfXtMuH2fJF1W" alt=""><figcaption></figcaption></figure>

Vâng nhìn cơ bản là kiểm tra các phần của flag đó. Và chỉ cần đi qua hàm `check1` nữa là xong.

<figure><img src="/files/UC8NHejlv8OA1SBeWujk" alt=""><figcaption></figcaption></figure>

Đoạn code này sẽ lấy giá trị bằng giây của thời gian trên rồi coi nó là chuỗi. Lấy từng 2 ký tự đó chuyển thành số rồi chuyển thành ký tự thì ta sẽ nhận được:

<figure><img src="/files/XViVB0md88lzXwBptzLl" alt=""><figcaption></figcaption></figure>

Và&#x20;

<figure><img src="/files/hsD0Khsc9j4MQfLfHZlp" alt=""><figcaption></figcaption></figure>

Kết hợp với phần sau thì sẽ ra được flag!!!!

## 8: 300 Load me up

Đối với bài này thì ta nhận được một file .bin mở xem dưới dạng hex thì không thấy có gì cả -> lấy đoạn mẵ hex đó đem đi disasembly xem sao (link: <https://defuse.ca/online-x86-assembler.htm>)

```
Disassembly:
0:  31 db                   xor    ebx,ebx          ;ebx = 0
2:  31 c9                   xor    ecx,ecx          ;ecx = 0
4:  66 b9 01 04             mov    cx,0x401         ;cx = 0x401
8:  f7 e3                   mul    ebx
a:  53                      push   ebx
b:  b8 42 44 05 0a          mov    eax,0xa054442
10: 35 77 77 77 77          xor    eax,0x77777777   ;eax = 0x7D723335 "}r35"
15: 50                      push   eax
16: 31 c0                   xor    eax,eax          ;eax = 0
18: b8 7d 7d 4e 64          mov    eax,0x644e7d7d  
1d: 35 11 11 11 11          xor    eax,0x11111111   ;eax = 0x755F6C6C  "u_ll"
22: 50                      push   eax
23: 31 c0                   xor    eax,eax
25: b8 48 06 5b 00          mov    eax,0x5b0648
2a: 35 33 33 33 33          xor    eax,0x33333333   ;eax = 0x3368357B  "3h5{"
2f: 50                      push   eax
30: 31 c0                   xor    eax,eax
32: b8 47 56 41 0d          mov    eax,0xd415647
37: 35 22 22 22 22          xor    eax,0x22222222   ;eax = 0x2F637465 "/cte"
3c: 50                      push   eax
3d: 31 c0                   xor    eax,eax          ;eax = 0
3f: 8d 1c 24                lea    ebx,[esp]
42: b0 05                   mov    al,0x5
44: cd 80                   int    0x80
46: 93                      xchg   ebx,eax
47: f7 e2                   mul    edx
49: b8 d9 c2 85 85          mov    eax,0x8585c2d9
4e: 35 aa aa aa aa          xor    eax,0xaaaaaaaa   ;eax  "//hs" 
53: 50                      push   eax
54: 31 c0                   xor    eax,eax
56: b8 d9 d2 d5 94          mov    eax,0x94d5d2d9
5b: 35 bb bb bb bb          xor    eax,0xbbbbbbbb   ;eax "/nib"
60: 50                      push   eax
61: 31 c0                   xor    eax,eax
63: b8 f6 e3 f6 e3          mov    eax,0xe3f6e3f6
68: 35 cc cc cc cc          xor    eax,0xcccccccc   ;eax "/:/:"
6d: 50                      push   eax
6e: 31 c0                   xor    eax,eax
70: b8 ed e7 ed e7          mov    eax,0xe7ede7ed
75: 35 dd dd dd dd          xor    eax,0xdddddddd   ;eax ":0:0"
7a: 50                      push   eax
7b: 31 c0                   xor    eax,eax
7d: b8 30 37 6f 6f          mov    eax,0x6f6f3730
82: 35 55 55 55 55          xor    eax,0x55555555   ;eax "::be"
87: 50                      push   eax
88: 31 c0                   xor    eax,eax
8a: b8 d7 cc fa df          mov    eax,0xdffaccd7
8f: 35 88 88 88 88          xor    eax,0x88888888   ;eax "WrD_"
94: 50                      push   eax
95: 31 c0                   xor    eax,eax
97: 8d 0c 24                lea    ecx,[esp]
9a: b2 14                   mov    dl,0x14
9c: b0 04                   mov    al,0x4
9e: cd 80                   int    0x80
a0: 2c 13                   sub    al,0x13
a2: cd 80                   int    0x80
```

-> ta nhận được flag: `DrWeb{5h3ll_u53r}`.

## 9: 300 Dungeon Master

Code của chương trình:

<figure><img src="/files/1x3lE1dKtTILZJ3CyUBx" alt=""><figcaption></figcaption></figure>

Nhiệm vụ gồm 3 level mình cần vượt qua để lấy flag. Qua kiểm tra level 1 và level 2 khá dễ thì ta nhận được đoạn ANS và KEY1 và KEY2 thì ta sẽ đi vào level3 bằng command:

```
./game -l1 "c:fiog By73r m_000" -l2 0---open door---0
```

<figure><img src="/files/y0tWE8BjcM2MpKh13hzL" alt=""><figcaption></figcaption></figure>

và đây là đoạn kiểm tra trong cuộc tấn công:

```c
 v0 = time(0LL);
  srand(v0);
  *v7 = rand() % 60 + 67;
  printf("Dragon is attacking! %d\n", (unsigned int)*v7);
  __isoc99_scanf("%s", nptr);
  v2 = atoi(nptr);
  if ( *v7 + v2 <= 64 || *v7 + v2 > 72 )
    goto LABEL_11;
  *v7 += v2;
  v7[1] = rand() % 40 + 87;
  printf("Nice! Can you counter it? %d\n", (unsigned int)v7[1]);
  __isoc99_scanf("%s", nptr);
  v3 = atoi(nptr);
  if ( v7[1] + v3 <= 79 || v7[1] + v3 > 90 )
    goto LABEL_11;
  v7[1] += v3;
  v7[2] = rand() % 71 + 56;
  printf("Good. But Dragon still there: %d\n", (unsigned int)v7[2]);
  __isoc99_scanf("%s", nptr);
  v4 = atoi(nptr);
  if ( v7[2] + v4 <= 34 || v7[2] + v4 > 38 )
    goto LABEL_11;
  v7[2] += v4;
  v7[3] = rand() % 53 + 74;
  printf("Oh no, he is furious. Defend! %d\n", (unsigned int)v7[3]);
  __isoc99_scanf("%s", nptr);
  v5 = atoi(nptr);
  if ( v7[3] + v5 <= 96 || v7[3] + v5 > 107 )
    goto LABEL_11;
  v7[3] += v5;
  v7[4] = rand() % 78 + 49;
  printf("You are almost winning. There is the last hit %d\n", (unsigned int)v7[4]);
  __isoc99_scanf("%s", nptr);
  v6 = atoi(nptr);
  if ( v7[4] + v6 > 113 && v7[4] + v6 <= 122 )
  {
    v7[4] += v6;
    printf("CONGRATULATION!\nThe loot dropped from dragon. And now it's yours!\n DrWeb{%s}\n[ENTER] to exit.\n", v7);
    while ( getchar() != 10 )
      ;
    return 1LL;
  }
  else
  {
LABEL_11:
    puts("Dragon is stronger than you!\nRun away or will be BBQ'ed! Catch your breath and try again.");
    return 0LL;
  }
```

Đối với bài này thì nhiều kết quả được ghi nhận vì giá trị ngẫu nhiên `time(0L)`. Như vậy nên tôi sẽ dừng lại tại đây.

## 10: 300 The essence of art is DrWeb!

Nhận được 1 bức ảnh -> nó dễ nhưng không biết làm thế nào là được -> xem lời giải là bài được viết bằng ngôn ngữ Piet. (link: <https://gabriellesc.github.io/piet/index.html>)

<figure><img src="/files/dbxh8OCsdbXCJkYPKBHa" alt=""><figcaption></figcaption></figure>

## 11: 300 Tickets, please

***

Nguồn: [https://habr.com/ru/companies/drweb/articles](https://habr.com/ru/companies/drweb/articles/)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://viettaliii.gitbook.io/home/ctf/write-up/drweb-2023.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
