├── README.md
├── algorithm
├── README.md
├── dictionary
│ ├── chall-00.md
│ ├── chall-01.md
│ ├── chall-02.md
│ ├── chall-03.md
│ ├── chall-04.md
│ ├── chall-05.md
│ ├── chall-06.md
│ ├── chall-07.md
│ ├── chall-08.md
│ ├── chall-09.md
│ └── chall-10.md
├── list
│ ├── chall-00.md
│ ├── chall-01.md
│ ├── chall-02.md
│ ├── chall-03.md
│ ├── chall-04.md
│ ├── chall-05.md
│ ├── chall-06.md
│ ├── chall-07.md
│ ├── chall-08.md
│ ├── chall-09.md
│ ├── chall-10.md
│ ├── chall-11.md
│ ├── chall-12.md
│ ├── chall-13.md
│ ├── chall-14.md
│ ├── chall-15.md
│ └── chall-16.md
├── number
│ ├── chall-00.md
│ ├── chall-01.md
│ └── chall-02.md
├── regex
│ ├── chall-00.md
│ ├── chall-01.md
│ ├── chall-02.md
│ ├── chall-03.md
│ ├── chall-04.md
│ ├── chall-05.md
│ ├── chall-06.md
│ └── chall-07.md
└── string
│ ├── chall-00.md
│ ├── chall-01.md
│ ├── chall-02.md
│ ├── chall-03.md
│ ├── chall-04.md
│ ├── chall-05.md
│ ├── chall-06.md
│ ├── chall-07.md
│ ├── chall-08.md
│ ├── chall-09.md
│ └── chall-10.md
├── binary
├── README.md
├── disassembly
│ ├── chall-00.md
│ ├── chall-01.md
│ ├── chall-02.md
│ ├── chall-03.md
│ ├── chall-04.md
│ ├── chall-05.md
│ └── resources
│ │ ├── sample-00.bin
│ │ ├── sample-00.nasm
│ │ ├── sample-01.bin
│ │ ├── sample-01.nasm
│ │ ├── sample-02.bin
│ │ ├── sample-02.nasm
│ │ ├── sample-03
│ │ └── sample-03.nasm
├── interoperable
│ ├── chall-00.md
│ ├── chall-01.md
│ ├── chall-02.md
│ ├── chall-03.md
│ └── resources
│ │ ├── clib-32.dll
│ │ ├── clib-32.so
│ │ ├── clib-64.dll
│ │ ├── clib-64.so
│ │ ├── clib-dll.c
│ │ └── clib-so.c
└── parsing
│ ├── chall-00.md
│ ├── chall-01.md
│ ├── chall-02.md
│ ├── chall-03.md
│ ├── chall-04.md
│ ├── chall-05.md
│ ├── chall-06.md
│ ├── chall-07.md
│ ├── chall-08.md
│ ├── chall-09.md
│ └── chall-10.md
├── bruteforce
├── README.md
├── fuzzing
│ ├── chall-00.md
│ ├── chall-01.md
│ ├── chall-02.md
│ └── chall-03.md
└── wordlist-gen
│ ├── chall-00.md
│ ├── chall-01.md
│ ├── chall-02.md
│ ├── chall-03.md
│ ├── chall-04.md
│ └── chall-05.md
├── crypto
├── README.md
├── cipher
│ ├── asymmetric
│ │ ├── chall-00.md
│ │ ├── chall-01.md
│ │ ├── chall-02.md
│ │ ├── chall-03.md
│ │ ├── chall-04.md
│ │ ├── chall-05.md
│ │ └── chall-06.md
│ ├── attack
│ │ ├── chall-00.md
│ │ ├── chall-01.md
│ │ ├── chall-02.md
│ │ └── chall-03.md
│ ├── block
│ │ ├── chall-00.md
│ │ ├── chall-01.md
│ │ ├── chall-02.md
│ │ ├── chall-03.md
│ │ ├── chall-04.md
│ │ ├── chall-05.md
│ │ ├── chall-06.md
│ │ └── chall-07.md
│ ├── classic
│ │ ├── chall-00.md
│ │ ├── chall-01.md
│ │ ├── chall-02.md
│ │ ├── chall-03.md
│ │ ├── chall-04.md
│ │ ├── chall-05.md
│ │ ├── chall-06.md
│ │ └── chall-07.md
│ └── stream
│ │ └── chall-00.md
├── encode
│ ├── chall-00.md
│ ├── chall-01.md
│ ├── chall-02.md
│ ├── chall-03.md
│ └── chall-04.md
└── hash
│ ├── chall-00.md
│ ├── chall-01.md
│ ├── chall-02.md
│ ├── chall-03.md
│ ├── chall-04.md
│ └── chall-05.md
├── files
├── README.md
├── access
│ ├── chall-00.md
│ └── chall-01.md
├── compression
│ ├── chall-00.md
│ ├── chall-01.md
│ ├── chall-02.md
│ ├── chall-03.md
│ ├── chall-04.md
│ ├── chall-05.md
│ └── resources
│ │ ├── sample-00.bin
│ │ ├── sample-01.bin
│ │ ├── sample-02.bin
│ │ ├── sample-03.bin
│ │ ├── sample-04.tar
│ │ └── sample-05.zip
├── parsing
│ ├── chall-00.md
│ ├── chall-01.md
│ ├── chall-02.md
│ ├── chall-03.md
│ ├── chall-04.md
│ ├── chall-05.md
│ └── resources
│ │ ├── sample-00.txt
│ │ ├── sample-01.bin
│ │ ├── sample-02a.csv
│ │ ├── sample-02b.csv
│ │ ├── sample-03.bin
│ │ └── sample-04.bin
└── raw
│ └── chall-00.md
├── network
├── README.md
├── protocol
│ ├── client
│ │ ├── chall-00.md
│ │ ├── chall-01.md
│ │ ├── chall-02.md
│ │ ├── chall-03.md
│ │ ├── chall-04.md
│ │ ├── chall-05.md
│ │ ├── chall-06.md
│ │ ├── chall-07.md
│ │ ├── chall-08.md
│ │ ├── chall-09.md
│ │ ├── chall-10.md
│ │ ├── chall-11.md
│ │ ├── chall-12.md
│ │ └── chall-13.md
│ └── server
│ │ ├── chall-00.md
│ │ ├── chall-01.md
│ │ ├── chall-02.md
│ │ ├── chall-03.md
│ │ ├── chall-04.md
│ │ ├── chall-05.md
│ │ └── chall-06.md
└── socket
│ ├── client
│ ├── chall-00.md
│ ├── chall-01.md
│ ├── chall-02.md
│ ├── chall-03.md
│ └── chall-04.md
│ ├── raw
│ ├── chall-00.md
│ ├── chall-01.md
│ ├── chall-02.md
│ └── chall-03.md
│ └── server
│ ├── chall-00.md
│ ├── chall-01.md
│ ├── chall-02.md
│ ├── chall-03.md
│ ├── chall-04.md
│ ├── chall-05.md
│ ├── chall-06.md
│ └── chall-07.md
├── process
├── README.md
├── multiprocess
│ ├── chall-00.md
│ ├── chall-01.md
│ └── chall-02.md
├── multithread
│ ├── chall-00.md
│ ├── chall-01.md
│ ├── chall-02.md
│ └── chall-03.md
└── subprocess
│ ├── chall-00.md
│ ├── chall-01.md
│ ├── chall-02.md
│ ├── chall-03.md
│ └── resources
│ ├── echoer
│ ├── echoer.c
│ ├── echoer.exe
│ ├── runme
│ ├── runme.c
│ └── runme.exe
└── web
├── README.md
├── requests
├── chall-00.md
├── chall-01.md
├── chall-02.md
├── chall-03.md
├── chall-04.md
├── chall-05.md
├── chall-06.md
├── chall-07.md
└── chall-08.md
└── scraping
├── chall-00.md
├── chall-01.md
├── chall-02.md
├── chall-03.md
├── chall-04.md
├── chall-05.md
├── chall-06.md
└── chall-07.md
/README.md:
--------------------------------------------------------------------------------
1 | # Pythonidae Challenge
2 |
3 | Learn Python for Cyber Security by completing challenges.
4 |
5 | ### Overview
6 |
7 | Programming is the heart of problem solving. And you heard that people in cyber security love Python very much. Whether you are offensive or defensive, writing efficient scripts are helpful for your daily routines.
8 |
9 | Python is simple and flexible. Extensive libraries make Python wonderful for working on common tasks. In short, Python provide entire spectrum of features to create powerful and novel programs.
10 |
11 | So you know Python, but you wonder how can you apply it to Cyber Security field? Where to start?
12 |
13 | We've built a collection of exercise that guide you to apply your Python programming knowledge into Cyber Security. We believe that a script is a collection of smaller tasks. Thus, completing task can help in creating complex code for your needs.
14 |
15 | ### What are the rules?
16 |
17 | First of all, we only provide tasks and you can complete it on your own pace. We don't provide any solution and don't ask us for them.
18 |
19 | You can use any approach to tackle the problems. Use existing library or create your own, do whatever you want. We don't restrict your creativity. You can also publish your ellegant and efficient solution. We don't mind.
20 |
21 | Stuck on something? You are allowed to ask help from others. Discuss the problem and experiment. But we don't encourage you to ask for the code. Solving them by yourself is very satisfying, don't you think so?
22 |
23 | And last, enjoy the game.
24 |
25 | ### How much Python do I need to know?
26 |
27 | Basically, no deep and complex knowledge on Python is used. You can even learn Python while work on `Pythonidae Challenge` in parallel.
28 |
29 | However, we suggest you to at least know basic of Python before you start. Let's say: decision making, loop, and functions.
30 |
31 | ### What should I expect?
32 |
33 | Our challenges are divided into some sets. Each set contain various challenge which get progressively harder. You can solve the set individually. To make it more exciting, these challenges are based on real-world tasks found in making script for Cyber Security field.
34 |
35 | Some tasks can be solved by writing one simple function. Some might need couple of them.
36 |
37 | ### Who did this?
38 |
39 | - Dicky Hermansyah | [github:dickyher-lab](https://github.com/dickyher-lab)
40 | - Digit Oktavianto | [github:digitoktavianto](https://github.com/digitoktavianto)
41 | - M. Dzikri Ramdhani | [github:HadrianCorbett](https://github.com/HadrianCorbett)
42 | - Satria Ady Pradana | [github:xathrya](https://github.com/xathrya)
43 |
44 | Pythonidae is maintained and expanded by `xathrya`, in conjunction with MII Cybersec Team at [Mitra Integrasi Informatika](https://mii.co.id).
45 |
46 | Want to add some challenges? Pull Requests are always welcomed.
--------------------------------------------------------------------------------
/algorithm/README.md:
--------------------------------------------------------------------------------
1 | # Pythonidae Challenge
2 |
3 | Learn Python for Cyber Security by completing challenges.
4 |
5 | ## Algorithm
6 |
7 | This is `Algorithm Set`. We challenge you to use algorithm (and data structure) for simple data processing.
8 |
9 | This challenge may not be directly related to Cyber Security. But efficiently processing data is the key for succesful operation.
10 |
11 | ## Contents
12 |
13 | You will see
14 |
15 | - `String` manipulation
16 | - `Number` operation
17 | - `List` manipulation
18 | - `Dictionary` manipulation
19 | - `Regular Expression`
20 |
21 | #### String Manipulation
22 |
23 | Modify partial or whole string and transform it to our needs.
24 |
25 | 0. Convert an `str` string to bytes string and get the length.
26 | 1. Given string `U` and list of string `E`. Create a new list by concatenating `U` with each element of `E`.
27 | 2. Given string `D`. Rewrite substring from index `S` to `E` by filling with `x`.
28 | 3. Given integer `N`, `S`, `E`. Create a `bytearray` with length `N`. Fill index `S` to `E` with random number.
29 | 4. Extract a valid URL (starts with `http://` or `https://`) from a very long string.
30 | 5. Decode a hexpair string to bytes.
31 | 6. Do `XOR` with a single byte for each caracter of a given string.
32 | 7. Do `XOR` of two hexpair string with same length.
33 | 8. Do `XOR` of two hexpair string with different length.
34 | 9. Print all permutation of string.
35 | 10. Given string `S` and array of integer `P`. Do reposition using `P` as index of new string.
36 |
37 | #### Number Operation
38 |
39 | 0. compute the `GCD` of two numbers.
40 | 1. list all factors of N.
41 | 2. check the range which include the given integer.
42 |
43 | #### List Manipulation
44 |
45 | 0. find maximum element from non-sorted list.
46 | 1. multiply each element of list with `3`
47 | 2. sum all item of odd index.
48 | 3. given list of string, sort by length.
49 | 4. take all unique element from list.
50 | 5. pick all unique element from list.
51 | 6. pick random item from list.
52 | 7. shuffle the position of each item.
53 | 8. flatten 2-dimension list to 1-dimension list.
54 | 9. given integer S and E with S < E. Create a list of unique integer with value in the range S to E. The position of value is random.
55 | 10. given a string S, create a list of integer with each element is ASCII representation of S.
56 | 11. pick all items common in two list.
57 | 12. zipping element of two list.
58 | 13. partition, split a list every N items.
59 | 14. partition, split a list into N partitions.
60 | 15. build a list of integers starting from 1 to `N`, excluding multiples of `K`.
61 | 16. range expansion.
62 |
63 | #### Dictionary Manipulation
64 |
65 | 0. add value to dictionary only if key not exists.
66 | 1. create a list of all keys (without values).
67 | 2. create a list of all values (without keys).
68 | 3. create a dictionary with key is a number from 1 to N.
69 | 4. given a string, create a dictionary where `key` is a character appear on string and the `value` is the number of occurrence.
70 | 5. delete key if exists.
71 | 6. delete key which has certain value.
72 | 7. create a dictionary by list of Keys and Values.
73 | 8. given list of dictionary, sort the list by the value of certain key.
74 | 9. given list of dictionary, remove certain key from each dictionary.
75 | 10. create a list of dictionary by two lists as values.
76 |
77 | #### Regular Expression
78 |
79 | Regular Expression, or regex, is a special text string for describing a search pattern.
80 |
81 | 0. find and extract IP address (IPv4)
82 | 1. find and extract IP address (IPv6)
83 | 2. find and extract domain name.
84 | 3. find and extract valid email address.
85 | 4. find and extract SSN (Social Security Number).
86 | 5. find and extract 3-digit numbers.
87 | 6. find and extract HTML tag.
88 | 7. find and extract fields from /etc/shadow password.
--------------------------------------------------------------------------------
/algorithm/dictionary/chall-00.md:
--------------------------------------------------------------------------------
1 | ## Challenge 00
2 |
3 | Given a dictionary `D`, pair of string `K` and `V`.
4 |
5 | Add value `V` only if the specified key `K` is not exists. No value replaced.
6 |
7 | ## Remarks
8 |
9 | Conditional insertion.
--------------------------------------------------------------------------------
/algorithm/dictionary/chall-01.md:
--------------------------------------------------------------------------------
1 | ## Challenge 01
2 |
3 | Given a dictionary `D`.
4 |
5 | Create a list of all the keys without the values.
6 |
7 | ## Test
8 |
9 | Given a dictionary `D`
10 |
11 | ```
12 | {
13 | "name": "xathrya",
14 | "hp": "100",
15 | "mp": "32"
16 | }
17 | ```
18 |
19 | should produce
20 |
21 | ```
22 | [ "name", "hp", "mp" ]
23 | ```
--------------------------------------------------------------------------------
/algorithm/dictionary/chall-02.md:
--------------------------------------------------------------------------------
1 | ## Challenge 02
2 |
3 | Given a dictionary `D`.
4 |
5 | Create a list of all the values without the keys.
6 |
7 | ## Test
8 |
9 | Given a dictionary `D`
10 |
11 | ```
12 | {
13 | "name": "xathrya",
14 | "hp": "100",
15 | "mp": "32"
16 | }
17 | ```
18 |
19 | should produce
20 |
21 | ```
22 | [ "xathrya", "100", "32" ]
23 | ```
--------------------------------------------------------------------------------
/algorithm/dictionary/chall-03.md:
--------------------------------------------------------------------------------
1 | ## Challenge 03
2 |
3 | Given a number `N`.
4 |
5 | Generate a dictionary where the key is a number from `1` to `N` and the value will be square of the key.
6 |
7 | ## Test
8 |
9 | given `N = 5`, the following dictionary will be produced.
10 |
11 | ```
12 | { 1: 1, 2: 4, 3: 9, 4: 16, 5: 25 }
13 | ```
14 |
15 | ## Remarks
16 |
17 | Dictionary comprehension to generate dictionary with criteria.
--------------------------------------------------------------------------------
/algorithm/dictionary/chall-04.md:
--------------------------------------------------------------------------------
1 | ## Challenge 04
2 |
3 | Given a string `S`.
4 |
5 | Create a dictionary where the key is a character and the value is the number of its appearance in the string.
6 |
7 | Only existing character appear in the dictionary.
8 |
9 | ## Test
10 |
11 | Given a string
12 |
13 | ```
14 | MII Cybersec
15 | ```
16 |
17 | will give result
18 |
19 | ```
20 | {
21 | 'M': 1,
22 | 'I': 2,
23 | ' ': 1,
24 | 'C': 1,
25 | 'y': 1,
26 | 'b': 1,
27 | 'e': 2,
28 | 'r': 1,
29 | 's': 1,
30 | 'c': 1
31 | }
32 | ```
33 |
34 | ## Remarks
35 |
36 | Frequency counting with dictionary.
--------------------------------------------------------------------------------
/algorithm/dictionary/chall-05.md:
--------------------------------------------------------------------------------
1 | ## Challenge 05
2 |
3 | Given a dictionary `D` and a string `K`.
4 |
5 | Delete key `K` if exist.
6 |
7 | ## Test
8 |
9 | Given a dictionary
10 |
11 | ```
12 | {
13 | "key1": 0,
14 | "key2": 2,
15 | "key3": 5,
16 | }
17 | ```
18 |
19 | deleting `key2` will give result
20 |
21 | ```
22 | {
23 | "key1": 0,
24 | "key3": 5,
25 | }
26 | ```
--------------------------------------------------------------------------------
/algorithm/dictionary/chall-06.md:
--------------------------------------------------------------------------------
1 | ## Challenge 06
2 |
3 | Given a dictionary `D` and value `V`.
4 |
5 | Delete every key which have value `V`.
6 |
7 | Note: as alternative, create new dictionary which had eliminated the keys.
8 |
9 | ## Test
10 |
11 | Given a dictionary
12 |
13 | ```
14 | {
15 | "key1": 0,
16 | "key2": 2,
17 | "key3": 5,
18 | "key4": 5,
19 | }
20 | ```
21 |
22 | Removing all keys which have value 5 will give result
23 |
24 | ```
25 | {
26 | "key1": 0,
27 | "key2": 2,
28 | }
29 | ```
30 |
31 | ## Remarks
32 |
33 | Filtering by value.
--------------------------------------------------------------------------------
/algorithm/dictionary/chall-07.md:
--------------------------------------------------------------------------------
1 | ## Challenge 07
2 |
3 | Given two lists `K` and `V`.
4 |
5 | Create a dictionary where the key-value pair is combination of `K` and `V` at same index.
6 |
7 | Note: handle the case when the length of two lists are not equal.
8 |
9 | ## Test
10 |
11 | Given two list, `K` and `V`
12 |
13 | ```
14 | K = [ "name", "hp", "mp" ]
15 | V = [ "xathrya", "100", "32" ]
16 | ```
17 |
18 | will produce new dictionary
19 |
20 | ```
21 | {
22 | "name": "xathrya",
23 | "hp": "100",
24 | "mp": "32"
25 | }
26 | ```
27 |
28 | ## Remarks
29 |
30 | Create dictionary by list of keys and values.
--------------------------------------------------------------------------------
/algorithm/dictionary/chall-08.md:
--------------------------------------------------------------------------------
1 | ## Challenge 08
2 |
3 | Given a list of dictionary `L` and key `K`.
4 |
5 | Sort the list by the value of key `K`.
6 |
7 | ## Test
8 |
9 | Given a list
10 |
11 | ```
12 | [ {'key': 1}, {'key': 10}, {'key': 5} ]
13 | ```
14 |
15 | using `key` as pivot, the list would be sorted as
16 |
17 | ```
18 | [ {'key': 1}, {'key': 5}, {'key': 10} ]
19 | ```
20 |
21 | ## Remarks
22 |
23 | Sort list of dictionary. Dictionary can be a representation of JSON.
--------------------------------------------------------------------------------
/algorithm/dictionary/chall-09.md:
--------------------------------------------------------------------------------
1 | ## Challenge 09
2 |
3 | Given a list of dictionary `L`.
4 |
5 | Remove a common key from each items.
6 |
7 | There is no guarantee that the key exists on each item (dictionary).
8 |
9 | Note: handle exclusion, where certain key is important and must not be removed.
10 |
11 | ## Test
12 |
13 | Given a list
14 |
15 | ```
16 | [ {'id':'1', 'room': '404', 'duration': '4'}, {'id':'2', 'room':'405'} ]
17 | ```
18 |
19 | Removing key `room` from every list item.
20 |
21 | ```
22 | [ {'id':'1', 'duration': '4'}, {'id':'2'} ]
23 | ```
24 |
25 | As seen, `id` is important key in this case to identified each item
--------------------------------------------------------------------------------
/algorithm/dictionary/chall-10.md:
--------------------------------------------------------------------------------
1 | ## Challenge 10
2 |
3 | Given two lists `N` and `C`.
4 |
5 | Create a new list of dictionaries. The dictionary has two entries, `name` and `code`. The `name` is assigned by element of `N` and `code` is assigned by element of `C`.
6 |
7 | Note: `N` and `C` is guaranteed to be equal length.
8 |
9 | ## Test
10 |
11 | Given two list, `N` and `C`
12 |
13 | ```
14 | N = [ "black", "red", "maroon", "yellow" ]
15 | C = [ "#000000", "#FF0000", "#800000", "#FFFF00" ]
16 | ```
17 |
18 | will produce new list
19 |
20 | ```
21 | [ {'name': 'Black', 'code': '#000000'}, {'name': 'Red', 'code': '#FF0000'}, {'name': 'Maroon', 'code': '#800000'}, {'name': 'Yellow', 'code': '#FFFF00'} ]
22 | ```
23 |
24 | ## Remarks
25 |
26 | Create a new type of collection by list existing of data.
--------------------------------------------------------------------------------
/algorithm/list/chall-00.md:
--------------------------------------------------------------------------------
1 | ## Challenge 00
2 |
3 | Given a list of integer `L`.
4 |
5 | Get the largest number from the list.
6 |
7 | There is no guarantee that the list is in ordered (sorted) condition.
8 |
9 | If the largest number appear multiple time, return them all.
10 |
11 | ## Test
12 |
13 | Given a list of integer `L`
14 |
15 | ```
16 | [ 4, 5, 1, 6, 7, 2, 8, 9, 1, 6, 9 ]
17 | ```
18 |
19 | the largest number from the list is `9`, so the result is `[9, 9]`.
20 |
21 | ## Remarks
22 |
23 | Filtering item of the list based on some criteria.
24 |
25 | The result might be a single item or sublist. The filtering can be thought as simple iteration and processing of each item in the list.
26 |
27 | Filtering is useful to obtain right item for the operation such as selecting correct payload based on target.
--------------------------------------------------------------------------------
/algorithm/list/chall-01.md:
--------------------------------------------------------------------------------
1 | ## Challenge 01
2 |
3 | Given a list of integer `L`.
4 |
5 | Multiplies all items with 3.
6 |
7 | ## Test
8 |
9 | Given a list of integer `L`
10 |
11 | ```
12 | [ 1, 6, 7, 2, 8 ]
13 | ```
14 |
15 | the result is:
16 |
17 | ```
18 | [ 3, 18, 21, 6, 24 ]
19 | ```
20 |
21 | ## Remarks
22 |
23 | Map or transform.
24 |
25 | Processing every items on collection in uniform. Giving same treatment on all elements. It is also possible to process in concurrent (parallel execution).
26 |
27 | Map is useful for applying some action on multiple objects, such as sending command to connected agents/implants simultaneously.
--------------------------------------------------------------------------------
/algorithm/list/chall-02.md:
--------------------------------------------------------------------------------
1 | ## Challenge 02
2 |
3 | Given a list of integer. Sum all items in odd index (i.e: 1, 3, 5, ...).
4 |
5 | Note: first item is index 0.
6 |
7 | ## Test
8 |
9 | Given list of integer
10 |
11 | ```
12 | [ 3, 0, 4, 9, 7, 9, 7, 2, 9, 4, 1, 4, 2, 5, 5, 7, 4, 0, 6, 9 ]
13 | ```
14 |
15 | the sum of odd-index value is: `40`
16 |
17 | ## Remarks
18 |
19 | Fold or accumulate.
20 | Get single result (conclusion) by combining multiple objects.
--------------------------------------------------------------------------------
/algorithm/list/chall-03.md:
--------------------------------------------------------------------------------
1 | ## Challenge 03
2 |
3 | Given a list of string with various length.
4 |
5 | Sort (ascending) the list based on their length.
6 |
7 | ## Test
8 |
9 | Given list of string
10 |
11 | ```
12 | MII-CyberSec
13 | Xathrya
14 | Reversing.ID
15 | ```
16 |
17 | sorting by the length will give result:
18 |
19 | ```
20 | Xathrya
21 | MII-CyberSec
22 | Reversing.ID
23 | ```
24 |
25 | ## Remarks
26 |
27 | Sort the list based on criteria.
--------------------------------------------------------------------------------
/algorithm/list/chall-04.md:
--------------------------------------------------------------------------------
1 | ## Challenge 04
2 |
3 | Given a list `L`.
4 |
5 | Remove the duplicate items on `L`.
6 |
7 | ## Test
8 |
9 | Given a list `L`
10 |
11 | ```
12 | [ 1, 1, 2, 3, 4, 4, 6, 9 ]
13 | ```
14 |
15 | removing duplicate items, we produce
16 |
17 | ```
18 | [ 1, 2, 3, 4, 6, 9 ]
19 | ```
--------------------------------------------------------------------------------
/algorithm/list/chall-05.md:
--------------------------------------------------------------------------------
1 | ## Challenge 05
2 |
3 | Given a list `L`.
4 |
5 | Create a list `U` where the items is unique (not repeating) values from `L`.
6 |
7 | ## Test
8 |
9 | Given a list `L`
10 |
11 | ```
12 | [ 1, 1, 2, 3, 4, 4, 6, 9 ]
13 | ```
14 |
15 | extracting all unique values will produce:
16 |
17 | ```
18 | [ 2, 3, 6, 9 ]
19 | ```
--------------------------------------------------------------------------------
/algorithm/list/chall-06.md:
--------------------------------------------------------------------------------
1 | ## Challenge 06
2 |
3 | Given a list `L`.
4 |
5 | Choose item randomly from `L`.
6 |
7 | Create two version, where:
8 | - chosen item is kept in `L`.
9 | - chosen item is discard from `L`.
--------------------------------------------------------------------------------
/algorithm/list/chall-07.md:
--------------------------------------------------------------------------------
1 | ## Challenge 07
2 |
3 | Given a list `L`.
4 |
5 | Shuffle the position of all items. Shuffling is repositioning each item to random place. Modification is in-place and no new list created.
6 |
7 | ## Test
8 |
9 | Given a list of integer `L`.
10 |
11 | ```
12 | [ 3, 2, 6, 7, 2 ]
13 | ```
14 |
15 | One of possible result from shuffling is:
16 |
17 | ```
18 | [ 6, 2, 7, 2, 3 ]
19 | ```
--------------------------------------------------------------------------------
/algorithm/list/chall-08.md:
--------------------------------------------------------------------------------
1 | ## Challenge 08
2 |
3 | Given `L`, a 2-dimension list (list of list) with various length.
4 |
5 | Concatenate all items and make 1-dimension list.
6 |
7 | ## Testing
8 |
9 | Given a list of list of integer.
10 |
11 | ```
12 | [ [2, 4, 3], [1, 5, 6], [9], [7, 9] ]
13 | ```
14 |
15 | which will produce:
16 |
17 | ```
18 | [ 2, 4, 3, 1, 5, 6, 9, 7, 9 ]
19 | ```
20 |
21 | ## Remarks
22 |
23 | Flatten the shallow list.
24 |
25 | Flattening is creating a new list by combining (concatenating) all member of list. This is useful if you have large results from different sources and only interest in the item itself. Processing 1-dimension list is simpler than 2-dimension list.
--------------------------------------------------------------------------------
/algorithm/list/chall-09.md:
--------------------------------------------------------------------------------
1 | ## Challenge 09
2 |
3 | Given two integers `S` and `E`, with `S` less than `E`.
4 |
5 | Create a list of unique (non-repeating) integers with value from `S` to `E`. The position of the value is random.
6 |
7 | ## Test
8 |
9 | Given integer `S = 3`, `E = 10`. One of possible result will be:
10 |
11 | ```
12 | [ 3, 8, 7, 4, 10, 9, 6, 5 ]
13 | ```
14 |
15 | From `S = 3` to `E = 10`, there are 8 integers.
--------------------------------------------------------------------------------
/algorithm/list/chall-10.md:
--------------------------------------------------------------------------------
1 | ## Challenge 10
2 |
3 | Given a string `S`.
4 |
5 | Create list of integer. Each element is ASCII representation of `S`.
6 |
7 | ## Test
8 |
9 | Given a string `S`
10 |
11 | ```
12 | "MII"
13 | ```
14 |
15 | representing the string as list of character would give
16 |
17 | ```
18 | [ 'M', 'I', 'I' ]
19 | ```
20 |
21 | converting each element to integer will produce:
22 |
23 | ```
24 | [ 77, 73, 73 ]
25 | ```
--------------------------------------------------------------------------------
/algorithm/list/chall-11.md:
--------------------------------------------------------------------------------
1 | ## Challenge 11
2 |
3 | Given two lists `L` & `M`.
4 |
5 | Find the common items from two lists.
6 |
7 | ## Test
8 |
9 | Given two list, `L` and `M`
10 |
11 | ```
12 | L = [ 1, 2, 3, 4, 5, 6, 7 ]
13 | M = [ 2, 6, 10, 12 ]
14 | ```
15 |
16 | will produce new list
17 |
18 | ```
19 | [ 2, 6 ]
20 | ```
21 |
22 | ## Remarks
23 |
24 | Finding intersected items.
--------------------------------------------------------------------------------
/algorithm/list/chall-12.md:
--------------------------------------------------------------------------------
1 | ## Challenge 12
2 |
3 | Given two lists `L` & `M`.
4 |
5 | Create a new list which each item is tuple of item from both list at the same index.
6 |
7 | Only perform the action on existing element.
8 |
9 | ## Test
10 |
11 | Given two list, L and M
12 |
13 | ```
14 | L = [ 1, 3, 5, 7, 9 ]
15 | M = [ 2, 4, 6 ]
16 | ```
17 |
18 | will produce new list
19 |
20 | ```
21 | [ (1, 2), (3, 4), (5, 6) ]
22 | ```
23 |
24 | ## Remarks
25 |
26 | Zipping element of two lists.
27 |
28 | Zipping usually used to pair two items, which work together.
--------------------------------------------------------------------------------
/algorithm/list/chall-13.md:
--------------------------------------------------------------------------------
1 | ## Challenge 13
2 |
3 | Given a list `L` and integer `N`.
4 |
5 | Split list every N-th element.
6 |
7 | If the size of `L` is not multiple of `N`, then the last partition might have less member than the rest.
8 |
9 | ## Test
10 |
11 | Given a list `L` (length = 14)
12 |
13 | ```
14 | [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n' ]
15 | ```
16 |
17 | using `N = 3`, it will produce
18 |
19 | ```
20 | [ ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'], ['j', 'k', 'l'], ['m', 'n'] ]
21 | ```
22 |
23 | ## Remarks
24 |
25 | Partitioning or splitting the list into several blocks of equal length.
26 |
27 | Partitioning is useful to divide the load so we can distribute it into several workers and executed concurrently.
--------------------------------------------------------------------------------
/algorithm/list/chall-14.md:
--------------------------------------------------------------------------------
1 | ## Challenge 14
2 |
3 | Given a list `L` and integer `N`.
4 |
5 | Split list into `N` partitions.
6 |
7 | If the size of `L` is not multiple of `N`, some blocks might have less member than the rest.
8 |
9 | ## Test
10 |
11 | Given a list `L` (length = 14)
12 |
13 | ```
14 | [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n' ]
15 | ```
16 |
17 | using `N = 3`, it will produce
18 |
19 | ```
20 | [ ['a', 'b', 'c', 'd', 'e'], ['f', 'g', 'h', 'i', 'j'], ['k', 'l', 'm', 'n'] ]
21 | ```
22 |
23 | the first and second partition (block) has 5 members while the last block has 4.
24 |
25 | ## Remarks
26 |
27 | Partitioning or splitting the list into several blocks of equal length.
28 |
29 | Partitioning is useful to divide the load so we can distribute it into several workers and executed concurrently.
--------------------------------------------------------------------------------
/algorithm/list/chall-15.md:
--------------------------------------------------------------------------------
1 | ## Challenge 15
2 |
3 | Given an integer `N` and `K`.
4 |
5 | Build list of number starting at 1 and up to but not including `N`. The list also exclude any number which is multiple of `K`.
6 |
7 | ## Test
8 |
9 | Given an integer `N = 15` and `K = 4`.
10 |
11 | The list should be `[1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14]`
12 |
13 | ## Remarks
14 |
15 | Generating a list with a criteria.
--------------------------------------------------------------------------------
/algorithm/list/chall-16.md:
--------------------------------------------------------------------------------
1 | ## Challenge 16
2 |
3 | Given a string of comma-separated integers `L`. Instead of an integer, some elements might be written as range `a-b` (two numbers separated by dash), with a <> b.
4 |
5 | For each ranges, replace with individual numbers in that range.
6 |
7 | ## Test
8 |
9 | Given list `L`.
10 |
11 | ```
12 | L = [1,3,5-9,13]
13 | ```
14 |
15 | should produce
16 |
17 | ```
18 | [1,3,5,6,7,8,9,13]
19 | ```
20 |
21 | ## Remarks
22 |
23 | Range expansion.
--------------------------------------------------------------------------------
/algorithm/number/chall-00.md:
--------------------------------------------------------------------------------
1 | ## Challenge 00
2 |
3 | Given two integers `A` and `B`.
4 |
5 | Find the `Greatest Common Divisor` between these two.
6 |
7 | ## Test
8 |
9 | Given two integers `A = 15` and `B = 27`. The `GCD` of both integer is 3.
10 |
11 | ## Remarks
12 |
13 | GCD is one of important concept in Discrete Math, especially some topics on Cryptography.
--------------------------------------------------------------------------------
/algorithm/number/chall-01.md:
--------------------------------------------------------------------------------
1 | ## Challenge 01
2 |
3 | Given an integer `N`.
4 |
5 | List all of its factors.
6 |
7 | ## Test
8 |
9 | Given an integer `N = 120`, which value can be written as `2^3 x 3 x 5` (^ means power). Then the factors are `2, 3, 5`
10 |
11 | ## Remarks
12 |
13 | Some number can be decomposed as product (multiplication) of prime numbers. This process is also known as factorization. Factorization is important process in Discrete Math especially some topics on Cryptography.
--------------------------------------------------------------------------------
/algorithm/number/chall-02.md:
--------------------------------------------------------------------------------
1 | ## Challenge 02
2 |
3 | Given a list of tuple representing a range (Start - End) and an integer `I`.
4 |
5 | Find out if there is any range which include the integer `I`.
6 |
7 | ## Test
8 |
9 | Given a list of tuple
10 |
11 | ```
12 | (0x00400000, 0x006fa000)
13 | (0x008f9000, 0x008fa000)
14 | (0x008fa000, 0x00986000)
15 | (0x00986000, 0x009a2000)
16 | (0x021ba000, 0x022a4000)
17 | (0x7f343d797000, 0x7f343de79000)
18 | (0x7f343de79000, 0x7f343df7e000)
19 | (0x7f343df7e000, 0x7f343e17d000)
20 | (0x7f343e17d000, 0x7f343e17e000)
21 | (0x7f343f000000, 0x7f343f1b6000)
22 | (0x7f343f1c5000, 0x7f343f1cc000)
23 | (0x7f343f1cc000, 0x7f343f1ce000)
24 | (0x7f343f1ce000, 0x7f343f1cf000)
25 | (0x7f343f1cf000, 0x7f343f1d0000)
26 | (0x7f343f1d0000, 0x7f343f1d1000)
27 | (0x7ffccf1fd000, 0x7ffccf21e000)
28 | (0x7ffccf23c000, 0x7ffccf23e000)
29 | (0x7ffccf23e000, 0x7ffccf240000)
30 | ```
31 |
32 | an integer `0x7f343f010210` is in the range of `(0x7f343f000000, 0x7f343f1b6000)`.
33 |
34 | ## Remarks
35 |
36 | Section of executable binary will be mapped to a memory region at load time. Sometimes, we need to locate the memory region which an address belong to.
--------------------------------------------------------------------------------
/algorithm/regex/chall-00.md:
--------------------------------------------------------------------------------
1 | ## Challenge 00
2 |
3 | Given a possible long text, find and extract valid IPv4 addresses.
4 |
5 | An IPv4 address consists of 4 segments, separated by a dots. Each segment is a value ranged from 0 to 255.
--------------------------------------------------------------------------------
/algorithm/regex/chall-01.md:
--------------------------------------------------------------------------------
1 | ## Challenge 01
2 |
3 | Given a possible long text, find and extract valid IPv6 addresses.
4 |
5 | An IPv6 address consists of 8 segments, separated by colons. Each segment is four hexadecimal digits which value ranged from 0 to ffff.
6 |
7 | If there are consecutive zeros, the IP representation can be shortened. For example, `2001:0db8:0000:0000:0000:8a2e:0370:7334` become `2001:0db8::8a2e:370:7334`.
--------------------------------------------------------------------------------
/algorithm/regex/chall-02.md:
--------------------------------------------------------------------------------
1 | ## Challenge 02
2 |
3 | Given a possible long text, find and extract domain names.
4 |
5 | Domain name consists of several string, separated by dots. The right most string is top-level domain, which value is defined (i.e. com, net, id, org). The rest are defining hostnames, which can be any arbitrary string.
6 |
7 | ## Remarks
8 |
9 | Some malware use communication with Command and Control server over DNS. The message is transported as DNS request/reply. To ensure communication, a random subdomain is generated using Domain Generation Algorithm.
--------------------------------------------------------------------------------
/algorithm/regex/chall-03.md:
--------------------------------------------------------------------------------
1 | ## Challenge 03
2 |
3 | Given a possible long text, find and extract valid email addresses.
4 |
5 | An email address consists of two parts username and domain, which separated by @.
--------------------------------------------------------------------------------
/algorithm/regex/chall-04.md:
--------------------------------------------------------------------------------
1 | ## Challenge 04
2 |
3 | Find and capture SSN (Social Security Number) from long text.
4 |
5 | A SSN is any series of 9 consecutive digits. SSN consists of 3 digits followed by delimit (space/dash), then 2 digits followed by delimit (space/dash), then 4 digits. Common format for writing SSN could be:
6 |
7 | * XXX YY ZZZZ
8 | * XXX-YY-ZZZZ
9 | * XXXYYZZZZ
10 |
11 | ## Remarks
12 |
13 | SSN or Social Security Number is number to identified citizens, permanent residents, and temporary (working) residents of USA.
14 |
15 | The purpose of SSN is to track the earning histories of US worksers, for use in determining Social Security benefit entitlement and computing benefit levels.
--------------------------------------------------------------------------------
/algorithm/regex/chall-05.md:
--------------------------------------------------------------------------------
1 | ## Challenge 05
2 |
3 | Given a long text `S`.
4 |
5 | Find and extract only 3-digit numbers. If 3 digits are part of larger number (4 or more digits) then this number is excluded.
6 |
7 | The 3-digit numbers must be preceeded by and followed by a non-word character.
8 |
9 | ## Test
10 |
11 | Given `S`
12 |
13 | ```
14 | 123 56789 013
15 | ```
16 |
17 | will result only 123 and 013.
--------------------------------------------------------------------------------
/algorithm/regex/chall-06.md:
--------------------------------------------------------------------------------
1 | ## Challenge 06
2 |
3 | Given a possible long text, find and extract HTML tags and list its attibutes.
4 |
5 | HTML elements is defined by tags and content. A tag, like XML tag, is a string enclosed by angle braces `<>`. Some popular tags are `
`, ``, `