2023-04-25 07:22:03 +00:00
|
|
|
|
# Paf'Py
|
|
|
|
|
|
|
|
|
|
Et PAF !
|
|
|
|
|
|
2023-04-25 16:44:42 +00:00
|
|
|
|
## TL;DR
|
2023-04-25 07:22:03 +00:00
|
|
|
|
|
2023-04-25 16:44:42 +00:00
|
|
|
|
Utilisez cette fonction `bash` :
|
2023-04-25 07:22:03 +00:00
|
|
|
|
|
2023-04-25 16:44:42 +00:00
|
|
|
|
```bash
|
|
|
|
|
paf()
|
|
|
|
|
{
|
|
|
|
|
curl https://p.afpy.org/ "${@/*/-F&=@&}"
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Cette fonction permet d'envoyer un fichier :
|
2023-04-25 07:22:03 +00:00
|
|
|
|
|
|
|
|
|
```bash
|
2023-04-25 16:44:42 +00:00
|
|
|
|
$ paf manage.py
|
|
|
|
|
- https://p.afpy.org/TaPa/manage.py
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Ou plusieurs :
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
$ paf *.py
|
|
|
|
|
- https://p.afpy.org/d6Xd/admin.py
|
|
|
|
|
- https://p.afpy.org/d6Xd/context_processors.py
|
|
|
|
|
- https://p.afpy.org/d6Xd/__init__.py
|
|
|
|
|
- https://p.afpy.org/d6Xd/models.py
|
|
|
|
|
- https://p.afpy.org/d6Xd/urls.py
|
|
|
|
|
- https://p.afpy.org/d6Xd/utils.py
|
|
|
|
|
- https://p.afpy.org/d6Xd/views.py
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Utilisation avec curl
|
|
|
|
|
|
|
|
|
|
En utilisant des requêtes `multipart/form-data` il est possible d'envoyer un fichier :
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
$ curl https://p.afpy.org/ -Fmanage.py=@manage.py
|
|
|
|
|
- https://p.afpy.org/TaPa/manage.py
|
2023-04-25 07:22:03 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
ou plusieurs fichiers en même temps :
|
|
|
|
|
|
|
|
|
|
```bash
|
2023-04-25 16:44:42 +00:00
|
|
|
|
$ curl https://p.afpy.org/ -Fmanage.py=@manage.py -Frequirements.txt=@requirements.txt
|
|
|
|
|
- https://p.afpy.org/Nz2o/manage.py
|
|
|
|
|
- https://p.afpy.org/Nz2o/requirements.txt
|
2023-04-25 07:22:03 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
C'est l'extension dans le nom du fichier qui permet de choisir la
|
|
|
|
|
coloration syntaxique pour chaque fichier.
|
|
|
|
|
|
|
|
|
|
|
2023-04-25 16:44:42 +00:00
|
|
|
|
### Envoyer dans le corps d'une requête
|
2023-04-25 07:22:03 +00:00
|
|
|
|
|
|
|
|
|
Il est possible de coller un unique fichier via le corps d'une requête POST :
|
|
|
|
|
|
|
|
|
|
```bash
|
2023-04-25 16:44:42 +00:00
|
|
|
|
$ cal | curl -XPOST --data-binary @- https://p.afpy.org/
|
|
|
|
|
- https://p.afpy.org/mo8X
|
2023-04-25 07:22:03 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Dans ce cas, il est possible de choisir la coloration syntaxique via l'entête `Content-Type` :
|
|
|
|
|
|
|
|
|
|
```bash
|
2023-04-25 16:44:42 +00:00
|
|
|
|
$ cal | curl -XPOST -H "Content-Type: text/plain" --data-binary @- https://p.afpy.org/
|
|
|
|
|
- https://p.afpy.org/i3Y2/request.txt
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Choisir l'URL
|
|
|
|
|
|
|
|
|
|
Il est possible d'utiliser la méthode `PUT` sur une `URL` :
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
$ cal | curl -XPUT --data-binary @- https://p.afpy.org/cal
|
|
|
|
|
- https://p.afpy.org/cal
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
$ curl -XPUT --data-binary @manage.py https://p.afpy.org/manage.py
|
|
|
|
|
- https://p.afpy.org/manage.py
|
2023-04-25 07:22:03 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
2023-04-25 16:44:42 +00:00
|
|
|
|
### Écraser un paste existant
|
|
|
|
|
|
|
|
|
|
Lors du premier envoi d'un paste, vous pouvez lui affecter un secret via l'entête HTTP `Authorization` :
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
$ date | curl -XPUT --data-binary @- -H "Authorization: Secret supersecret" https://p.afpy.org/date
|
|
|
|
|
- https://p.afpy.org/date
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Ainsi vous pouvez mettre à jour ce `paste` en utilisant la même URL et le même secret :
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
$ date | curl -XPUT --data-binary @- -H "Authorization: Secret supersecret" https://p.afpy.org/date
|
|
|
|
|
- https://p.afpy.org/date
|
|
|
|
|
$ curl https://p.afpy.org/date
|
|
|
|
|
Tue Apr 25 06:22:45 PM CEST 2023
|
|
|
|
|
$ date | curl -XPUT --data-binary @- -H "Authorization: Secret supersecret" https://p.afpy.org/date
|
|
|
|
|
- https://p.afpy.org/date
|
|
|
|
|
$ curl https://p.afpy.org/date
|
|
|
|
|
Tue Apr 25 06:23:44 PM CEST 2023
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
La page d'accueil est maintenue de cette manière la.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Lister ses envois
|
|
|
|
|
|
|
|
|
|
Tous les envois effectiés avec le même secret peuvent être listés via l'URL `/::/list/` :
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
$ curl https://p.afpy.org/::/list/ -H "Authorization: Secret supersecret"
|
|
|
|
|
| filename | size | URL | paste_time | access_time | viewcount |
|
|
|
|
|
|------------|--------|---------------------|---------------------------|---------------------------|-------------|
|
|
|
|
|
| | 5168 | https://p.afpy.org/ | 2023-04-25T16:03:59+00:00 | 2023-04-25T16:26:59+00:00 | 2 |
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Utilisation avancée
|
|
|
|
|
|
|
|
|
|
Avec cette fonction (dont le secret doit être personalisé) :
|
2023-04-25 07:22:03 +00:00
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
paf()
|
|
|
|
|
{
|
2023-04-25 16:44:42 +00:00
|
|
|
|
local SECRET="supersecret"
|
|
|
|
|
local AUTH="-HAuthorization: Secret $SECRET"
|
|
|
|
|
local INSTANCE="https://p.afpy.org/"
|
|
|
|
|
|
|
|
|
|
if [[ $1 == "--list" ]]
|
|
|
|
|
then
|
|
|
|
|
curl "$AUTH" $INSTANCE::/list/
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
|
2023-04-25 07:22:03 +00:00
|
|
|
|
if [[ $# == 0 ]]
|
|
|
|
|
then
|
2023-04-25 16:44:42 +00:00
|
|
|
|
curl "$AUTH" "$INSTANCE" --data-binary @-
|
2023-04-25 07:22:03 +00:00
|
|
|
|
else
|
2023-04-25 16:44:42 +00:00
|
|
|
|
curl "$AUTH" "$INSTANCE" "${@/*/-F&=@&}"
|
2023-04-25 07:22:03 +00:00
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2023-04-25 16:44:42 +00:00
|
|
|
|
Il est possible :
|
2023-04-25 07:22:03 +00:00
|
|
|
|
|
2023-04-25 16:44:42 +00:00
|
|
|
|
- d'envoyer un ou plusieurs fichiers,
|
|
|
|
|
- d'envoyer `stdin`,
|
|
|
|
|
- de lister ses envois.
|
2023-04-25 07:22:03 +00:00
|
|
|
|
|
2023-04-25 16:44:42 +00:00
|
|
|
|
Exemple d'envoi via `stdin` :
|
2023-04-25 07:22:03 +00:00
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
$ cal | paf
|
2023-04-25 16:44:42 +00:00
|
|
|
|
- https://p.afpy.org/aAkF
|
2023-04-25 07:22:03 +00:00
|
|
|
|
```
|
|
|
|
|
|
2023-04-25 16:44:42 +00:00
|
|
|
|
Si vous voulez partager un dossier complet, vous pouvez simplement envoyer la liste des URL qui vous est renvoyée :
|
2023-04-25 07:22:03 +00:00
|
|
|
|
|
|
|
|
|
```
|
2023-04-25 16:44:42 +00:00
|
|
|
|
$ paf *.py|paf
|
|
|
|
|
- https://p.afpy.org/nnLR
|
2023-04-25 07:22:03 +00:00
|
|
|
|
```
|
|
|
|
|
|
2023-04-25 16:44:42 +00:00
|
|
|
|
Ce qui donne :
|
2023-04-25 07:22:03 +00:00
|
|
|
|
|
|
|
|
|
```
|
2023-04-25 16:44:42 +00:00
|
|
|
|
$ curl https://p.afpy.org/nnLR
|
|
|
|
|
- https://p.afpy.org/fAqR/admin.py
|
|
|
|
|
- https://p.afpy.org/fAqR/context_processors.py
|
|
|
|
|
- https://p.afpy.org/fAqR/__init__.py
|
|
|
|
|
- https://p.afpy.org/fAqR/models.py
|
|
|
|
|
- https://p.afpy.org/fAqR/urls.py
|
|
|
|
|
- https://p.afpy.org/fAqR/utils.py
|
|
|
|
|
- https://p.afpy.org/fAqR/views.py
|
2023-04-25 07:22:03 +00:00
|
|
|
|
```
|
|
|
|
|
|
2023-04-25 16:44:42 +00:00
|
|
|
|
Et qui est rendu avec des liens cliquables en HTML !
|
|
|
|
|
|
2023-04-25 07:22:03 +00:00
|
|
|
|
|
|
|
|
|
## Accès aux collages
|
|
|
|
|
|
|
|
|
|
Chaque collage peut-être consulté dans un navigateur (où il est
|
2023-04-25 16:44:42 +00:00
|
|
|
|
présenté avec de la coloration syntaxique : https://p.afpy.org/manage.py),
|
|
|
|
|
ou être consulté en ligne de commande (où il est délivré brut) :
|
2023-04-25 07:22:03 +00:00
|
|
|
|
|
|
|
|
|
```
|
2023-04-25 16:44:42 +00:00
|
|
|
|
$ curl https://p.afpy.org/manage.py
|
2023-04-25 07:22:03 +00:00
|
|
|
|
#!/usr/bin/env python
|
|
|
|
|
import os
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "webtools.settings")
|
|
|
|
|
|
|
|
|
|
from django.core.management import execute_from_command_line
|
|
|
|
|
|
|
|
|
|
execute_from_command_line(sys.argv)
|
|
|
|
|
```
|