mirror of
https://github.com/carlospolop/hacktricks
synced 2024-11-22 20:53:37 +00:00
193 lines
14 KiB
Markdown
193 lines
14 KiB
Markdown
# Memcache Commands
|
|
|
|
{% hint style="success" %}
|
|
Leer & oefen AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
|
Leer & oefen GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
|
|
|
<details>
|
|
|
|
<summary>Ondersteun HackTricks</summary>
|
|
|
|
* Kyk na die [**subskripsie planne**](https://github.com/sponsors/carlospolop)!
|
|
* **Sluit aan by die** 💬 [**Discord groep**](https://discord.gg/hRep4RUj7f) of die [**telegram groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
|
* **Deel hacking truuks deur PRs in te dien na die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
|
|
|
|
</details>
|
|
{% endhint %}
|
|
|
|
<figure><img src="https://pentest.eu/RENDER_WebSec_10fps_21sec_9MB_29042024.gif" alt=""><figcaption></figcaption></figure>
|
|
|
|
{% embed url="https://websec.nl/" %}
|
|
|
|
|
|
## Commands Cheat-Sheet
|
|
|
|
**Van** [**https://lzone.de/cheat-sheet/memcached**](https://lzone.de/cheat-sheet/memcached)
|
|
|
|
Die ondersteunde opdragte (die amptelike en sommige onamptelike) is gedokumenteer in die [doc/protocol.txt](https://github.com/memcached/memcached/blob/master/doc/protocol.txt) dokument.
|
|
|
|
Ongelukkig is die sintaksis beskrywing nie regtig duidelik nie en 'n eenvoudige hulpopdrag wat die bestaande opdragte lys, sou baie beter wees. Hier is 'n oorsig van die opdragte wat jy in die [bron](https://github.com/memcached/memcached) kan vind (soos van 19.08.2016):
|
|
|
|
| Command | Description | Example |
|
|
| --------------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
| get | Lees 'n waarde | `get mykey` |
|
|
| set | Stel 'n sleutel onvoorwaardelik | <p><code>set mykey <flags> <ttl> <size></code><br><br><p>Maak seker om \r\n as lynbreuke te gebruik wanneer jy Unix CLI gereedskap gebruik. Byvoorbeeld</p> <code>printf "set mykey 0 60 4\r\ndata\r\n" | nc localhost 11211</code></p> |
|
|
| add | Voeg 'n nuwe sleutel by | `add newkey 0 60 5` |
|
|
| replace | Oorskryf bestaande sleutel | `replace key 0 60 5` |
|
|
| append | Voeg data by bestaande sleutel | `append key 0 60 15` |
|
|
| prepend | Voeg data voor bestaande sleutel | `prepend key 0 60 15` |
|
|
| incr | Verhoog numeriese sleutelwaarde met 'n gegewe getal | `incr mykey 2` |
|
|
| decr | Verminder numeriese sleutelwaarde met 'n gegewe getal | `decr mykey 5` |
|
|
| delete | Verwyder 'n bestaande sleutel | `delete mykey` |
|
|
| flush\_all | Maak alle items onmiddellik ongeldig | `flush_all` |
|
|
| flush\_all | Maak alle items in n sekondes ongeldig | `flush_all 900` |
|
|
| stats | Druk algemene statistieke | `stats` |
|
|
| | Druk geheue statistieke | `stats slabs` |
|
|
| | Druk hoër vlak toewysing statistieke | `stats malloc` |
|
|
| | Druk inligting oor items | `stats items` |
|
|
| | | `stats detail` |
|
|
| | | `stats sizes` |
|
|
| | Reset statistiek tellers | `stats reset` |
|
|
| lru\_crawler metadump | Dump (meeste van) die metadata vir (alle) die items in die cache | `lru_crawler metadump all` |
|
|
| version | Druk bediener weergawe. | `version` |
|
|
| verbosity | Verhoog logvlak | `verbosity` |
|
|
| quit | Beëindig sessie | `quit` |
|
|
|
|
#### Traffic Statistics <a href="#traffic-statistics" id="traffic-statistics"></a>
|
|
|
|
Jy kan die huidige verkeersstatistieke opvra met die opdrag
|
|
```
|
|
stats
|
|
```
|
|
U sal 'n lys ontvang wat die aantal verbindings, bytes in/uit en nog baie meer dien.
|
|
|
|
Voorbeeld Uitset:
|
|
```
|
|
STAT pid 14868
|
|
STAT uptime 175931
|
|
STAT time 1220540125
|
|
STAT version 1.2.2
|
|
STAT pointer_size 32
|
|
STAT rusage_user 620.299700
|
|
STAT rusage_system 1545.703017
|
|
STAT curr_items 228
|
|
STAT total_items 779
|
|
STAT bytes 15525
|
|
STAT curr_connections 92
|
|
STAT total_connections 1740
|
|
STAT connection_structures 165
|
|
STAT cmd_get 7411
|
|
STAT cmd_set 28445156
|
|
STAT get_hits 5183
|
|
STAT get_misses 2228
|
|
STAT evictions 0
|
|
STAT bytes_read 2112768087
|
|
STAT bytes_written 1000038245
|
|
STAT limit_maxbytes 52428800
|
|
STAT threads 1
|
|
END
|
|
```
|
|
#### Geheue Statistieke <a href="#memory-statistics" id="memory-statistics"></a>
|
|
|
|
Jy kan die huidige geheue statistieke opvra met
|
|
```
|
|
stats slabs
|
|
```
|
|
```markdown
|
|
# Memcache Commands
|
|
|
|
Memcached is a high-performance, distributed memory object caching system. It is used to speed up dynamic web applications by alleviating database load.
|
|
|
|
## Basic Commands
|
|
|
|
### set
|
|
|
|
Stel 'n waarde in vir 'n sleutel.
|
|
|
|
### get
|
|
|
|
Kry die waarde van 'n sleutel.
|
|
|
|
### delete
|
|
|
|
Verwyder 'n sleutel en sy waarde.
|
|
|
|
## Advanced Commands
|
|
|
|
### incr
|
|
|
|
Verhoog die waarde van 'n sleutel met 'n spesifieke bedrag.
|
|
|
|
### decr
|
|
|
|
Verlaag die waarde van 'n sleutel met 'n spesifieke bedrag.
|
|
|
|
### flush_all
|
|
|
|
Maak alle sleutels en waardes skoon.
|
|
|
|
## Conclusion
|
|
|
|
Memcached is 'n nuttige hulpmiddel vir die verbetering van webtoepassings se prestasie deur die vermindering van databasislas.
|
|
```
|
|
```
|
|
STAT 1:chunk_size 80
|
|
STAT 1:chunks_per_page 13107
|
|
STAT 1:total_pages 1
|
|
STAT 1:total_chunks 13107
|
|
STAT 1:used_chunks 13106
|
|
STAT 1:free_chunks 1
|
|
STAT 1:free_chunks_end 12886
|
|
STAT 2:chunk_size 100
|
|
STAT 2:chunks_per_page 10485
|
|
STAT 2:total_pages 1
|
|
STAT 2:total_chunks 10485
|
|
STAT 2:used_chunks 10484
|
|
STAT 2:free_chunks 1
|
|
STAT 2:free_chunks_end 10477
|
|
[...]
|
|
STAT active_slabs 3
|
|
STAT total_malloced 3145436
|
|
END
|
|
```
|
|
As jy onseker is of jy genoeg geheue het vir jou memcached instansie, kyk altyd na die “evictions” tellers wat deur die “stats” opdrag gegee word. As jy genoeg geheue vir die instansie het, behoort die “evictions” teller 0 te wees of ten minste nie te styg nie.
|
|
|
|
#### Watter Sleutels Word Gebruik? <a href="#which-keys-are-used" id="which-keys-are-used"></a>
|
|
|
|
Daar is geen ingeboude funksie om direk die huidige stel sleutels te bepaal nie. Maar jy kan die
|
|
```
|
|
stats items
|
|
```
|
|
```markdown
|
|
opdrag om te bepaal hoeveel sleutels bestaan.
|
|
```
|
|
```
|
|
stats items
|
|
STAT items:1:number 220
|
|
STAT items:1:age 83095
|
|
STAT items:2:number 7
|
|
STAT items:2:age 1405
|
|
[...]
|
|
END
|
|
```
|
|
Dit help ten minste om te sien of enige sleutels gebruik word. Om die sleutelname uit 'n PHP-skrip wat reeds die memcache-toegang doen, te dump, kan jy die PHP-kode van [100days.de](http://100days.de/serendipity/archives/55-Dumping-MemcacheD-Content-Keys-with-PHP.html) gebruik.
|
|
|
|
|
|
<figure><img src="https://pentest.eu/RENDER_WebSec_10fps_21sec_9MB_29042024.gif" alt=""><figcaption></figcaption></figure>
|
|
|
|
{% embed url="https://websec.nl/" %}
|
|
|
|
{% hint style="success" %}
|
|
Leer & oefen AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
|
Leer & oefen GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
|
|
|
<details>
|
|
|
|
<summary>Ondersteun HackTricks</summary>
|
|
|
|
* Kyk na die [**subskripsieplanne**](https://github.com/sponsors/carlospolop)!
|
|
* **Sluit aan by die** 💬 [**Discord-groep**](https://discord.gg/hRep4RUj7f) of die [**telegram-groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
|
* **Deel hacking truuks deur PRs in te dien na die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
|
|
|
|
</details>
|
|
{% endhint %}
|