2020-07-15 15:43:14 +00:00
|
|
|
# Magic Methods
|
|
|
|
|
|
|
|
## Class Methods
|
|
|
|
|
2021-11-30 13:55:54 +00:00
|
|
|
You can access the **methods **of a **class **using **\__dict\_\_.**
|
2020-07-15 15:43:14 +00:00
|
|
|
|
2021-10-18 11:21:18 +00:00
|
|
|
![](<../../.gitbook/assets/image (42).png>)
|
2020-07-15 15:43:14 +00:00
|
|
|
|
2021-11-30 13:55:54 +00:00
|
|
|
You can access the functions
|
2020-07-15 15:43:14 +00:00
|
|
|
|
2021-10-18 11:21:18 +00:00
|
|
|
![](<../../.gitbook/assets/image (45).png>)
|
2020-07-15 15:43:14 +00:00
|
|
|
|
|
|
|
## Object class
|
|
|
|
|
|
|
|
### **Attributes**
|
|
|
|
|
2021-11-30 13:55:54 +00:00
|
|
|
You can access the **attributes of an object** using** \__dict\_\_**. Example:
|
2020-07-15 15:43:14 +00:00
|
|
|
|
2021-10-18 11:21:18 +00:00
|
|
|
![](<../../.gitbook/assets/image (41).png>)
|
2020-07-15 15:43:14 +00:00
|
|
|
|
|
|
|
### Class
|
|
|
|
|
2021-11-30 13:55:54 +00:00
|
|
|
You can access the **class **of an object using **\__class\_\_**
|
2020-07-15 15:43:14 +00:00
|
|
|
|
2021-10-18 11:21:18 +00:00
|
|
|
![](<../../.gitbook/assets/image (43).png>)
|
2020-07-15 15:43:14 +00:00
|
|
|
|
2021-11-30 13:55:54 +00:00
|
|
|
You can access the **methods **of the **class **of an **object chainning **magic functions:
|
2020-07-15 15:43:14 +00:00
|
|
|
|
2021-10-18 11:21:18 +00:00
|
|
|
![](<../../.gitbook/assets/image (44).png>)
|
2020-07-15 15:43:14 +00:00
|
|
|
|
|
|
|
## Server Side Template Injection
|
|
|
|
|
2021-11-30 13:55:54 +00:00
|
|
|
Interesting functions to exploit this vulnerability
|
2020-07-15 15:43:14 +00:00
|
|
|
|
2021-10-18 11:21:18 +00:00
|
|
|
```
|
2020-07-15 15:43:14 +00:00
|
|
|
__init__.__globals__
|
|
|
|
__class__.__init__.__globals__
|
|
|
|
```
|
|
|
|
|
2021-10-18 11:21:18 +00:00
|
|
|
Inside the response search for the application (probably at the end?)
|
2020-07-15 15:43:14 +00:00
|
|
|
|
2021-11-30 13:55:54 +00:00
|
|
|
Then **access the environment content** of the application where you will hopefully find **some passwords **of interesting information:
|
2020-07-15 15:43:14 +00:00
|
|
|
|
2021-10-18 11:21:18 +00:00
|
|
|
```
|
2020-07-15 15:43:14 +00:00
|
|
|
__init__.__globals__[<name>].config
|
|
|
|
__init__.__globals__[<name>].__dict__
|
|
|
|
__init__.__globals__[<name>].__dict__.config
|
|
|
|
__class__.__init__.__globals__[<name>].config
|
|
|
|
__class__.__init__.__globals__[<name>].__dict__
|
|
|
|
__class__.__init__.__globals__[<name>].__dict__.config
|
|
|
|
```
|
|
|
|
|
|
|
|
## More Information
|
|
|
|
|
|
|
|
* [https://rushter.com/blog/python-class-internals/](https://rushter.com/blog/python-class-internals/)
|
|
|
|
* [https://docs.python.org/3/reference/datamodel.html](https://docs.python.org/3/reference/datamodel.html)
|
2021-11-30 13:55:54 +00:00
|
|
|
* [https://balsn.tw/ctf_writeup/20190603-facebookctf/#events](https://balsn.tw/ctf_writeup/20190603-facebookctf/#events)
|
2021-10-18 11:21:18 +00:00
|
|
|
* [https://medium.com/bugbountywriteup/solving-each-and-every-fb-ctf-challenge-part-1-4bce03e2ecb0](https://medium.com/bugbountywriteup/solving-each-and-every-fb-ctf-challenge-part-1-4bce03e2ecb0) (events)
|