-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmpcli
More file actions
executable file
·1643 lines (1476 loc) · 73.4 KB
/
Copy pathtmpcli
File metadata and controls
executable file
·1643 lines (1476 loc) · 73.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
"""
tmpcli: Universal command-line file uploader/downloader for temporary file hosts.
Project: tmp-cli — CLI binary: tmpcli
Supports 16+ services. No accounts required.
"""
import argparse
import hashlib
import json
import os
import random
import re
import shutil
import string
import subprocess
import sys
import time
import urllib.request
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from pathlib import Path
from typing import Dict, List, Optional, Tuple
from urllib.parse import urlparse
CATALOG = {
"catbox": {"upload":"✓","download":"✓","max_mb":200, "expiry":"permanent","notes":"Most reliable"},
"litterbox": {"upload":"✓","download":"✓","max_mb":1024, "expiry":"1h–72h", "notes":"Catbox temp sister"},
"temp.sh": {"upload":"✓","download":"✓","max_mb":4096, "expiry":"3 days", "notes":"Simple API"},
"gofile": {"upload":"✓","download":"✓","max_mb":0, "expiry":"variable","notes":"Dynamic token auth"},
"pixeldrain": {"upload":"🔑","download":"✓","max_mb":10240, "expiry":"60 days","notes":"Upload needs API key"},
"0x0": {"upload":"✓*","download":"✓","max_mb":512, "expiry":"30d–1y","notes":"Uploads often disabled by operator"},
"termbin": {"upload":"✗","download":"✓","max_mb":0, "expiry":"unknown","notes":"TCP 9999 often firewalled; service is intermittently down"},
"drop.plz.ac": {"upload":"✓","download":"✓","max_mb":100, "expiry":"60 min","notes":"Cloudflare-backed"},
"sharenation": {"upload":"✓","download":"✓","max_mb":250, "expiry":"1 min–1 day","notes":"+5-download safeguard"},
"x0.at": {"upload":"✓","download":"✓","max_mb":1024, "expiry":"unknown","notes":"CLI-friendly Austria host"},
"uguu": {"upload":"✓","download":"✓","max_mb":128, "expiry":"3 hours","notes":"Pomf.se fork"},
"tmpfiles": {"upload":"✓","download":"✓","max_mb":100, "expiry":"1 min–48h","notes":"/tmp/files rebrand"},
"filebin": {"upload":"✓","download":"✓","max_mb":0, "expiry":"unknown","notes":"Raw PUT, no expiry"},
"send.vis.ee": {"upload":"✓","download":"✓","max_mb":2500, "expiry":"1d/20dl","notes":"Requires ffsend CLI"},
"wormhole": {"upload":"✗","download":"✓","max_mb":10000, "expiry":"session","notes":"Interactive only; receive via wormhole receive <code>"},
"isrv": {"upload":"✓","download":"✓","max_mb":1024, "expiry":"7d–365d","notes":"Open source (isrv.nl); expiration auto-scaled by file size"},
"tempfile.org": {"upload":"✓","download":"✓","max_mb":100, "expiry":"1h–48h", "notes":"REST API; field name is 'files' not 'file'"},
"tmpfile.link": {"upload":"✓","download":"✓","max_mb":100, "expiry":"7 days", "notes":"Cloudflare Workers CDN; multi-host d1-d10.tfdl.net for binaries"},
"box.juicey.dev": {"upload":"✓","download":"✓","max_mb":2048, "expiry":"3 days", "notes":"Open-source; content-addressed (SHA-256 dedup); 10-files-per-IP cap"},
"originless": {"upload":"✓","download":"✓","max_mb":50, "expiry":"permanent","notes":"IPFS-backed (originless.gupt.app); CID = SHA-256; accessible via any IPFS gateway"},
"paste.rs": {"upload":"✓","download":"✓","max_mb":4, "expiry":"unknown","notes":"Text-only; raw POST body; modern termbin replacement"},
"fsend.me": {"upload":"✓","download":"✓","max_mb":200, "expiry":"7 days", "notes":"PUT-style upload; 200MB nginx cap; supports Max-Downloads/Max-Days headers"},
"fars.ee": {"upload":"✓","download":"✓","max_mb":10, "expiry":"unknown","notes":"pb fork; content-addressed; field=c; ?u=1 returns URL only"},
}
UPLOAD_SERVICES = [k for k in CATALOG if not k.startswith("_") and CATALOG[k]["upload"] != "✗"]
@dataclass
class UploadResult:
url: str
delete_url: Optional[str] = None
expires_in: str = ""
service: str = ""
file_id: str = ""
token: str = ""
size_mb: float = 0.0
elapsed: float = 0.0
def _fmt_size(size_mb: float) -> str:
if size_mb < 0.01:
return f"{size_mb*1024:.1f}KB"
if size_mb < 1024:
return f"{size_mb:.1f}MB"
return f"{size_mb/1024:.1f}GB"
def _fmt_time(s: float) -> str:
if s < 1:
return f"{s*1000:.0f}ms"
if s < 60:
return f"{s:.1f}s"
return f"{s/60:.1f}m"
def _fmt_speed(mbps: float) -> str:
if mbps < 0.01:
return f"{mbps*1024:.1f}KB/s"
return f"{mbps:.1f}MB/s"
@dataclass
class PerfRecord:
upload_times: List[float] = field(default_factory=list)
success_count: int = 0
failure_count: int = 0
avg_speed_mbps: float = 0.0
class BaseService(ABC):
name: str = ""
max_size_mb: int = 0
default_expiry: str = ""
supports_anon: bool = True
needs_key: bool = False
@abstractmethod
def upload(self, file_path: str, **kwargs) -> UploadResult:
pass
@abstractmethod
def download(self, url: str, output_path: str) -> bool:
pass
def _upload_timeout(self, file_path: str, min_t: int = 120, mbps: float = 1.5) -> int:
"""Size-aware upload timeout. min_t covers the 0-byte case; mbps is a
conservative worst-case upload speed (1.5 MB/s ≈ 12 Mbps). Used by every
service that uploads via _curl/_curl_browser, so a 1.4GB file gets a
~16min budget rather than the previous 120s hard cap that aborted every
large upload with a confusing "timeout" error."""
try:
size_mb = os.path.getsize(file_path) / (1024 * 1024)
except OSError:
return min_t
return max(min_t, int(size_mb / mbps) + 30) # +30s for connect/handshake
def _curl(self, args: List[str], capture_output=True, timeout=120) -> Tuple[int, str, str]:
# filebin's Varnish layer returns a 5KB anti-bot interstitial when it sees
# the bare tmpcli/1.1 UA. Most other services work fine with it, so the
# override is a per-call concern in filebin's service class.
cmd = ["curl", "-s", "-L", "-A", "tmpcli/1.1"] + args
try:
result = subprocess.run(cmd, capture_output=capture_output, text=True, timeout=timeout)
return result.returncode, result.stdout, result.stderr
except subprocess.TimeoutExpired:
return -1, "", "timeout"
except Exception as e:
return -1, "", str(e)
def _curl_browser(self, args: List[str], capture_output=True, timeout=120) -> Tuple[int, str, str]:
"""Variant that uses a real browser User-Agent — needed for filebin's Varnish bot filter."""
cmd = ["curl", "-s", "-L",
"-A", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"] + args
try:
result = subprocess.run(cmd, capture_output=capture_output, text=True, timeout=timeout)
return result.returncode, result.stdout, result.stderr
except subprocess.TimeoutExpired:
return -1, "", "timeout"
except Exception as e:
return -1, "", str(e)
def _req(self, url: str, method="GET", data=None, headers=None, json_resp=False, timeout=30):
"""Lightweight urllib wrapper for simple GET/POST."""
import json as _json
import urllib.request as _req
h = {"User-Agent": "tmpcli/1.1"}
if headers:
h.update(headers)
bod = data if data else None
rq = _req.Request(url, data=bod, headers=h, method=method)
try:
with _req.urlopen(rq, timeout=timeout) as resp:
body = resp.read()
if json_resp:
return True, _json.loads(body.decode())
return True, body.decode()
except Exception as e:
return False, str(e)
def _url_read(self, url: str, timeout=20) -> str:
"""Simple GET returning body text."""
return self._req(url, timeout=timeout)[1]
# ─── Services ──────────────────────────────────────────────────────────────
class CatboxService(BaseService):
name = "catbox"
max_size_mb = 200
default_expiry = "permanent"
def upload(self, file_path: str, **kwargs) -> UploadResult:
code, out, err = self._curl([
"-F", "reqtype=fileupload",
"-F", f"fileToUpload=@{file_path}",
"https://catbox.moe/user/api.php"
], timeout=self._upload_timeout(file_path))
if code != 0 or not out.startswith("http"):
raise RuntimeError(f"Catbox upload failed: {err or out}")
return UploadResult(url=out.strip(), service="catbox", expires_in="permanent")
def download(self, url: str, output_path: str) -> bool:
code, _, _ = self._curl(["-o", output_path, url])
return code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
class LitterboxService(BaseService):
name = "litterbox"
max_size_mb = 1024
default_expiry = "72h"
def upload(self, file_path: str, **kwargs) -> UploadResult:
time_param = kwargs.get("time_param", "72h")
code, out, err = self._curl([
"-F", "reqtype=fileupload",
"-F", f"time={time_param}",
"-F", f"fileToUpload=@{file_path}",
"https://litterbox.catbox.moe/resources/internals/api.php"
], timeout=self._upload_timeout(file_path))
if code != 0 or not out.startswith("http"):
raise RuntimeError(f"Litterbox upload failed: {err or out}")
return UploadResult(url=out.strip(), service="litterbox", expires_in=time_param)
def download(self, url: str, output_path: str) -> bool:
code, _, _ = self._curl(["-o", output_path, url])
return code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
class TempShService(BaseService):
name = "temp.sh"
max_size_mb = 4096
default_expiry = "3d"
def upload(self, file_path: str, **kwargs) -> UploadResult:
code, out, err = self._curl([
"-F", f"file=@{file_path}",
"https://temp.sh/upload"
], timeout=self._upload_timeout(file_path))
if code != 0 or not out.startswith(("https://", "http://")):
raise RuntimeError(f"temp.sh upload failed: {err or out}")
return UploadResult(url=out.strip().split()[0], service="temp.sh", expires_in="3 days")
def download(self, url: str, output_path: str) -> bool:
code, _, err = self._curl(["-X", "POST", "-o", output_path, url])
ok = code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
if not ok:
code2, _, _ = self._curl(["-o", output_path, "-L", url])
ok = code2 == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
return ok
class GofileService(BaseService):
name = "gofile"
max_size_mb = 0
default_expiry = "variable"
API_SALT = "g4f8fd9f12h14g"
UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
def _create_account(self) -> str:
import json as _json
import urllib.request as _req
rq = _req.Request(
"https://api.gofile.io/accounts",
data=b"",
headers={"Accept": "*/*", "User-Agent": self.UA, "Origin": "https://gofile.io", "Referer": "https://gofile.io/"},
method="POST",
)
try:
with _req.urlopen(rq, timeout=15) as resp:
data = _json.loads(resp.read().decode())
if data.get("status") == "ok":
return data["data"]["token"]
except Exception:
pass
return ""
def _generate_website_token(self, account_token: str) -> str:
timeslot = int(time.time()) // 14400
raw = f"{self.UA}::en-US::{account_token}::{timeslot}::{self.API_SALT}"
return hashlib.sha256(raw.encode()).hexdigest()
def upload(self, file_path: str, **kwargs) -> UploadResult:
_, serv_json, _ = self._curl(["-H", "Accept: application/json", "https://api.gofile.io/servers"])
server = "store-eu-par-2"
try:
data = json.loads(serv_json)
server = data["data"]["servers"][0]["name"]
except:
pass
code, out, err = self._curl(["-F", f"file=@{file_path}", f"https://{server}.gofile.io/contents/uploadfile"],
timeout=self._upload_timeout(file_path))
if code != 0:
raise RuntimeError(f"Gofile upload failed: {err}")
try:
resp = json.loads(out)
if resp.get("status") != "ok":
raise RuntimeError(f"Gofile API error: {resp}")
d = resp["data"]
return UploadResult(url=d["downloadPage"], service="gofile", expires_in="varies",
file_id=d["id"], token=d.get("guestToken", ""))
except json.JSONDecodeError:
raise RuntimeError(f"Gofile bad JSON: {out[:200]}")
def download(self, url: str, output_path: str) -> bool:
parsed = urlparse(url)
code = parsed.path.split("/")[-1]
account_token = self._create_account()
if not account_token:
return self._download_from_page(url, output_path, "")
wt = self._generate_website_token(account_token)
api_url = f"https://api.gofile.io/contents/{code}?cache=true"
jargs = ["-H", f"Authorization: Bearer {account_token}",
"-H", f"X-Website-Token: {wt}",
"-H", "X-Version: 2",
"-H", "X-BL: en-US",
"-H", f"User-Agent: {self.UA}",
"-H", "Origin: https://gofile.io",
"-H", "Referer: https://gofile.io/",
api_url]
_, api_json, _ = self._curl(jargs)
direct_link = ""
try:
api_resp = json.loads(api_json)
if api_resp.get("status") == "ok":
children = api_resp["data"].get("children", {})
if children:
fi = list(children.values())[0]
direct_link = fi.get("link", "")
except Exception as e:
print(f"[warn] gofile API parse error: {e}", file=sys.stderr)
if direct_link:
dl_args = ["-o", output_path,
"-H", f"Authorization: Bearer {account_token}",
"-H", f"X-Website-Token: {wt}",
"-H", f"User-Agent: {self.UA}",
"-H", "Origin: https://gofile.io",
"-H", "Referer: https://gofile.io/",
"-H", "Accept: */*",
"-b", f"accountToken={account_token}",
"-L", direct_link]
d_code, _, _ = self._curl(dl_args)
ok = d_code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
if ok:
return True
return self._download_from_page(url, output_path, "")
def _download_from_page(self, url: str, output_path: str, page_html: str) -> bool:
parsed = urlparse(url)
code = parsed.path.split("/")[-1]
patterns = [f"https://store1.gofile.io/download/{code}",
f"https://store-eu-par-2.gofile.io/download/{code}"]
for pat in patterns:
d_code, _, _ = self._curl(["-o", output_path, pat])
if d_code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0:
return True
return False
class NullPointerService(BaseService):
name = "0x0"
max_size_mb = 512
default_expiry = "30d-1y"
def upload(self, file_path: str, **kwargs) -> UploadResult:
args = ["-F", f"file=@{file_path}"]
if kwargs.get("secret"):
args += ["-F", "secret="]
if kwargs.get("expires"):
args += ["-F", f"expires={kwargs['expires']}"]
args += ["https://0x0.st"]
code, out, err = self._curl(args)
if "disabled" in (out + err).lower() or "botnet" in (out + err).lower():
raise RuntimeError("0x0.st: uploads temporarily disabled by operator")
if code != 0 or not out.startswith("http"):
raise RuntimeError(f"0x0.st upload failed: {err or out}")
url = out.strip().split()[0]
expires = f"~{kwargs.get('expires')}h" if kwargs.get("expires") else "auto"
return UploadResult(url=url, service="0x0", expires_in=expires)
def download(self, url: str, output_path: str) -> bool:
code, _, _ = self._curl(["-o", output_path, url])
return code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
class PixeldrainService(BaseService):
name = "pixeldrain"
max_size_mb = 10240
default_expiry = "60dl"
needs_key = True
def __init__(self, api_key: str = "", **kwargs):
self.api_key = api_key
if not self.api_key:
self.api_key = os.environ.get("PIXELDRAIN_API_KEY", "")
def upload(self, file_path: str, **kwargs) -> UploadResult:
if not self.api_key:
raise RuntimeError("pixeldrain upload requires API key. Get one at https://pixeldrain.com/user/api_keys")
code, out, err = self._curl(["-u", f"{self.api_key}:", "-F", f"file=@{file_path}", "https://pixeldrain.com/api/file"])
if code != 0:
raise RuntimeError(f"pixeldrain upload failed: {err}")
try:
resp = json.loads(out)
if not resp.get("success", True):
raise RuntimeError(f"pixeldrain API: {resp}")
fid = resp["id"]
return UploadResult(url=f"https://pixeldrain.com/u/{fid}", service="pixeldrain",
expires_in="60 days", file_id=fid)
except json.JSONDecodeError:
raise RuntimeError(f"pixeldrain bad JSON: {out[:200]}")
def download(self, url: str, output_path: str) -> bool:
m = re.search(r'pixeldrain\.com/u?/([A-Za-z0-9]+)', url)
if not m:
return False
fid = m.group(1)
dl_url = f"https://pixeldrain.com/api/file/{fid}"
code, _, _ = self._curl(["-o", output_path, dl_url])
return code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
class TermbinService(BaseService):
name = "termbin"
max_size_mb = 0
default_expiry = "unknown (text only)"
def upload(self, file_path: str, **kwargs) -> UploadResult:
# Termbin exposes a TCP paste service on port 9999. As of mid-2026 the
# TCP endpoint is often firewalled or unreachable from residential / cloud
# IPs, and the HTTPS endpoint returns 405 (legacy /upload route removed).
# We still try the TCP path first; if it fails we surface a clear error
# rather than silently failing.
with open(file_path, "rb") as f:
data = f.read()
if len(data) > 1024 * 512:
raise RuntimeError("termbin: file too large (>512KB text)")
import socket
s = None
try:
s = socket.create_connection(("termbin.com", 9999), timeout=15)
s.sendall(data + b"\n")
s.settimeout(15)
buf = b""
while True:
try:
chunk = s.recv(4096)
except socket.timeout:
break
if not chunk:
break
buf += chunk
if b"\n" in buf:
break
url = buf.decode().strip().split()[0] if buf else ""
if url.startswith("http"):
return UploadResult(url=url, service="termbin", expires_in="unknown")
except Exception as e:
last_err = str(e)
finally:
if s:
try: s.close()
except: pass
raise RuntimeError(
f"termbin unreachable (TCP 9999 timed out, HTTP /upload returns 405). "
f"Service is intermittently down — try again later. Last err: {last_err if 'last_err' in dir() else 'unknown'}"
)
def download(self, url: str, output_path: str) -> bool:
code, _, _ = self._curl(["-o", output_path, url])
return code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
class DropPlzAcService(BaseService):
name = "drop.plz.ac"
max_size_mb = 100
default_expiry = "60 min"
def upload(self, file_path: str, **kwargs) -> UploadResult:
code, out, err = self._curl(["-F", f"file=@{file_path}", "https://drop.plz.ac/upload"])
if code != 0:
raise RuntimeError(f"drop.plz.ac upload failed: {err}")
try:
resp = json.loads(out)
if not resp.get("success"):
raise RuntimeError(f"drop.plz.ac error: {resp}")
return UploadResult(url=resp["downloadUrl"], service="drop.plz.ac",
expires_in="60 min", file_id=resp.get("fileId", ""))
except json.JSONDecodeError:
raise RuntimeError(f"drop.plz.ac bad JSON: {out[:200]}")
def download(self, url: str, output_path: str) -> bool:
code, _, _ = self._curl(["-o", output_path, url])
return code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
class ShareNationService(BaseService):
name = "sharenation"
max_size_mb = 250
default_expiry = "1 min–1 day"
def upload(self, file_path: str, **kwargs) -> UploadResult:
import re
# sharenation `time` field is a Unix timestamp (seconds since epoch), NOT a duration.
# Passing 3600 (1970-01-01) instantly expires. Compute future timestamp.
expires_seconds = kwargs.get("expires_seconds", 86400) # default 1 day
# Cap to sharenation's apparent max window (~1 day)
expires_seconds = min(expires_seconds, 86400)
expires_ts = int(time.time()) + expires_seconds
code, out, err = self._curl([
"-F", f"file=@{file_path}",
"-F", f"time={expires_ts}",
"https://sharenation.org/upload"
])
# ShareNation returns HTML page with URL embedded; extract it
url_match = re.search(r'https://sharenation\.org/[a-zA-Z0-9_.-]+\.bin', out)
if code != 0 or not url_match:
raise RuntimeError(f"sharenation upload failed: {err or out[:200]}")
return UploadResult(url=url_match.group(0), service="sharenation",
expires_in=f"{expires_seconds}s")
def download(self, url: str, output_path: str) -> bool:
code, _, _ = self._curl(["-o", output_path, url])
return code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
class X0AtService(BaseService):
name = "x0.at"
max_size_mb = 1024
default_expiry = "unknown"
def upload(self, file_path: str, **kwargs) -> UploadResult:
code, out, err = self._curl(["-F", f"file=@{file_path}", "https://x0.at/"])
if code != 0 or not out.startswith("http"):
raise RuntimeError(f"x0.at upload failed: {err or out}")
return UploadResult(url=out.strip().split()[0], service="x0.at", expires_in="unknown")
def download(self, url: str, output_path: str) -> bool:
code, _, _ = self._curl(["-o", output_path, url])
return code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
class UguuService(BaseService):
name = "uguu"
max_size_mb = 128
default_expiry = "3 hours"
def upload(self, file_path: str, **kwargs) -> UploadResult:
code, out, err = self._curl(["-F", f"files[]=@{file_path}", "https://uguu.se/upload.php"])
if code != 0:
raise RuntimeError(f"uguu upload failed: {err}")
try:
resp = json.loads(out)
if not resp.get("success"):
raise RuntimeError(f"uguu error: {resp}")
files = resp.get("files", [])
if not files:
raise RuntimeError("uguu: no files in response")
return UploadResult(url=files[0]["url"], service="uguu",
expires_in="3 hours", file_id=files[0].get("hash", ""))
except json.JSONDecodeError:
raise RuntimeError(f"uguu bad JSON: {out[:200]}")
def download(self, url: str, output_path: str) -> bool:
code, _, _ = self._curl(["-o", output_path, url])
return code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
class TmpfilesService(BaseService):
name = "tmpfiles"
max_size_mb = 100
default_expiry = "1 min–48h"
def upload(self, file_path: str, **kwargs) -> UploadResult:
expires = kwargs.get("tmpfiles_expire", 3600)
code, out, err = self._curl([
"-F", f"file=@{file_path}",
"-F", f"expire={expires}",
"https://tmpfiles.org/api/v1/upload"
])
if code != 0:
raise RuntimeError(f"tmpfiles upload failed: {err}")
try:
resp = json.loads(out)
if resp.get("status") != "success":
raise RuntimeError(f"tmpfiles error: {resp}")
# API returns preview page URL (https://tmpfiles.org/<id>/<filename>)
# Direct download requires /dl/ prefix
preview_url = resp["data"]["url"]
direct_url = preview_url.replace("://tmpfiles.org/", "://tmpfiles.org/dl/", 1)
return UploadResult(url=direct_url, service="tmpfiles",
expires_in=f"{expires}s")
except json.JSONDecodeError:
raise RuntimeError(f"tmpfiles bad JSON: {out[:200]}")
def download(self, url: str, output_path: str) -> bool:
code, _, _ = self._curl(["-L", "-o", output_path, url])
return code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
class FilebinService(BaseService):
name = "filebin"
max_size_mb = 0
default_expiry = "unknown"
def upload(self, file_path: str, **kwargs) -> UploadResult:
bin_id = kwargs.get("filebin_bin") or "tmpcli" + "".join(random.choices(string.ascii_lowercase, k=6))
fname = kwargs.get("filename") or os.path.basename(file_path)
code, out, err = self._curl_browser([
"-X", "PUT",
"-H", "Content-type: application/octet-stream",
"--data-binary", f"@{file_path}",
f"https://filebin.net/{bin_id}/{fname}"
], timeout=self._upload_timeout(file_path))
if code not in (0,):
raise RuntimeError(f"filebin upload failed: {err}")
try:
resp = json.loads(out)
if resp.get("error"):
raise RuntimeError(f"filebin API error: {resp['error']}")
dl = f"https://filebin.net/{bin_id}/{fname}"
return UploadResult(url=dl, service="filebin", expires_in="unknown", file_id=bin_id)
except json.JSONDecodeError:
dl = f"https://filebin.net/{bin_id}/{fname}"
return UploadResult(url=dl, service="filebin", expires_in="unknown", file_id=bin_id)
def download(self, url: str, output_path: str) -> bool:
# Use browser UA — filebin's Varnish front returns an interstitial otherwise
code, _, _ = self._curl_browser(["-L", "-o", output_path, url])
return code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
class SendVisEeService(BaseService):
"""send.vis.ee wrapper — delegates to `ffsend` CLI."""
name = "send.vis.ee"
max_size_mb = 2500
default_expiry = "1d/20dl"
needs_key = False
def _ffsend(self) -> str:
"""Find ffsend executable."""
for cmd in ["ffsend"]:
if shutil.which(cmd):
return cmd
return ""
def upload(self, file_path: str, **kwargs) -> UploadResult:
ffs = self._ffsend()
if not ffs:
raise RuntimeError("send.vis.ee requires `ffsend` CLI. Install: cargo install ffsend || brew install ffsend")
expires = kwargs.get("expires_hours", 24)
# ffsend args: `upload -c <FILE> --host <URL>`. Old code had `upload --copy file <FILE>`
# which is wrong on two counts: --copy takes no value, and "file" was treated as a path.
# Also use -I (--no-interact) to suppress prompts.
try:
result = subprocess.run(
[ffs, "upload", "-I", "-c", file_path,
"--host", "https://send.vis.ee",
"-e", str(expires)],
capture_output=True, text=True, timeout=120
)
if result.returncode != 0:
raise RuntimeError(f"ffsend failed: {result.stderr}")
# URL is on stdout, but progress UI may also emit text. Find a line starting with http.
url = ""
for line in result.stdout.splitlines():
line = line.strip()
if line.startswith("http"):
# First token on the URL line
url = line.split()[0]
break
if not url:
raise RuntimeError(f"ffsend: no URL in output:\nstdout={result.stdout}\nstderr={result.stderr[:300]}")
return UploadResult(url=url, service="send.vis.ee", expires_in=f"{expires}h")
except subprocess.TimeoutExpired:
raise RuntimeError("ffsend upload timed out")
def download(self, url: str, output_path: str) -> bool:
ffs = self._ffsend()
if not ffs:
raise RuntimeError("send.vis.ee download requires `ffsend` CLI")
try:
result = subprocess.run(
[ffs, "download", url, "-o", output_path],
capture_output=True, text=True, timeout=120
)
return result.returncode == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
except subprocess.TimeoutExpired:
return False
class WormholeService(BaseService):
"""wormhole.app — interactive end-to-end encrypted transfer.
NOTE: Wormhole is fundamentally interactive. The sender generates a one-time
code, prints it to stdout, then blocks waiting for a receiver to enter it
on the other end. There is no persistent URL — once both sides have the
code, they negotiate a direct (or relayed) transfer. As such:
- `upload` here just produces the code and prints it. The transfer
completes only when a receiver uses `wormhole receive <code>`.
- `download` accepts a code and receives the file.
We surface this clearly in the error message and CLI output.
"""
name = "wormhole"
max_size_mb = 10000
default_expiry = "session-based"
needs_key = False
def _wh(self) -> str:
for cmd in ["wormhole", "wormhole-cli"]:
if shutil.which(cmd):
return cmd
return ""
def upload(self, file_path: str, **kwargs) -> UploadResult:
wh = self._wh()
if not wh:
raise RuntimeError("wormhole requires `wormhole` CLI. Install: pip install magic-wormhole")
# wormhole send prints a code and BLOCKS waiting for a receiver. We can't
# capture a URL — only the code. The right way to use this is interactive.
# For scripting, surface a clear error and let the user invoke it manually.
raise RuntimeError(
"wormhole is interactive-only: it generates a one-time code and waits "
"for a receiver to enter it. There is no URL to return. Run "
f"`{wh} send {file_path}` manually, share the code with the recipient, "
"and have them run `wormhole receive <code>`. For automated pipelines "
"use a real host (catbox, filebin, temp.sh, etc.) instead."
)
def download(self, url: str, output_path: str) -> bool:
# Accept either a code directly (e.g. "3-cactus-pelican") or a full wormhole.app URL.
wh = self._wh()
if not wh:
raise RuntimeError("wormhole download requires `wormhole` CLI")
code_match = re.search(r'#?(\d+-[a-z]+-[a-z]+)', url)
if not code_match:
return False
code = code_match.group(1)
try:
result = subprocess.run(
[wh, "receive", code, "-o", output_path],
capture_output=True, text=True, timeout=120
)
return result.returncode == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
except subprocess.TimeoutExpired:
return False
class IsrvService(BaseService):
"""isrv.nl — open-source anonymous file sharing.
Expiration semantics: default is auto-calculated from file size (7d for small
files up to 365d for tiny files, scaled by size). The `expires` form field
can be either hours (e.g. "24") or a Unix timestamp. Capped at 365d.
Returns JSON: {"status":"success","filename":"<url>","expiration":"<iso8601>"}.
"""
name = "isrv"
max_size_mb = 1024
default_expiry = "7d–365d"
def upload(self, file_path: str, **kwargs) -> UploadResult:
# expires can be hours (e.g. 24) or a unix timestamp. Default to 24h
# (86400 seconds) for predictable behavior; the server's auto-scaling
# may produce longer defaults.
expires = kwargs.get("expires_seconds", 86400)
# Cap to 365 days (isrv's documented max)
expires = min(expires, 365 * 86400)
code, out, err = self._curl([
"-F", f"file=@{file_path}",
"-F", f"expires={expires}",
"https://isrv.nl/"
])
if code != 0:
raise RuntimeError(f"isrv upload failed: {err}")
try:
resp = json.loads(out)
except json.JSONDecodeError:
raise RuntimeError(f"isrv bad JSON: {out[:200]}")
if resp.get("status") != "success":
raise RuntimeError(f"isrv API error: {resp}")
url = resp.get("filename", "")
if not url.startswith("http"):
raise RuntimeError(f"isrv: no filename in response: {resp}")
return UploadResult(url=url, service="isrv",
expires_in=resp.get("expiration", ""))
def download(self, url: str, output_path: str) -> bool:
code, _, _ = self._curl(["-L", "-o", output_path, url])
return code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
class TmpfileOrgService(BaseService):
"""tempfile.org — REST API, no account, 100MB cap, 1-48h expiry.
Important: multipart field name is `files` (not `file` or `files[]`).
Server returns JSON: {"success":true,"files":[{"id":..,"url":"https://tempfile.org/<id>/",..}]}.
Direct download URL is `<page_url>/download` (NOT the page itself).
"""
name = "tempfile.org"
max_size_mb = 100
default_expiry = "1h–48h"
# API endpoint
_API = "https://tempfile.org/api/upload/local"
def upload(self, file_path: str, **kwargs) -> UploadResult:
# Default 24h; valid values per API docs are 1, 6, 24, 48
hours = int(kwargs.get("expires_hours", 24))
if hours not in (1, 6, 24, 48):
hours = 24
code, out, err = self._curl([
"-F", f"files=@{file_path}", # NOTE: field is "files", not "file"
"-F", f"expiryHours={hours}",
self._API
])
if code != 0:
raise RuntimeError(f"tempfile.org upload failed: {err}")
try:
resp = json.loads(out)
except json.JSONDecodeError:
raise RuntimeError(f"tempfile.org bad JSON: {out[:200]}")
if not resp.get("success"):
raise RuntimeError(f"tempfile.org API error: {resp}")
files = resp.get("files", [])
if not files:
raise RuntimeError(f"tempfile.org: no files in response: {resp}")
f = files[0]
page_url = f.get("url", "")
# Direct download URL is the page URL + "download" (not the page itself
# which is an HTML preview)
direct_url = page_url.rstrip("/") + "/download"
return UploadResult(url=direct_url, service="tempfile.org",
expires_in=f"{hours}h", file_id=f.get("id", ""))
def download(self, url: str, output_path: str) -> bool:
code, _, _ = self._curl(["-L", "-o", output_path, url])
return code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
class FsendMeService(BaseService):
"""fsend.me — transfer.sh-inspired, 7-day default retention, raw PUT upload.
API is a single PUT to https://fsend.me/<filename> where the request body
is the file content (NOT multipart/form-data). Server returns the URL on
the response body. Optional headers:
- Max-Downloads: N (delete after N downloads)
- Max-Days: N (delete after N days, default 7)
The file path in the URL is the original filename; the server picks a
short hash prefix.
"""
name = "fsend.me"
max_size_mb = 200 # server-side nginx limit: 200MB passes, 201MB gets 413. Probed 2026-06-04.
default_expiry = "7 days"
def upload(self, file_path: str, **kwargs) -> UploadResult:
# Map our kwargs to fsend.me headers
# Default: no download cap, 7 days retention
max_downloads = kwargs.get("max_downloads", "")
max_days = kwargs.get("max_days", "")
filename = os.path.basename(file_path)
headers = ["-H", "Content-Type: application/octet-stream"]
if max_downloads:
headers += ["-H", f"Max-Downloads: {max_downloads}"]
if max_days:
headers += ["-H", f"Max-Days: {max_days}"]
# Use --upload-file (PUT) NOT -F (multipart)
cmd = ["curl", "-sS", "--upload-file", file_path] + headers + [f"https://fsend.me/{filename}"]
try:
r = subprocess.run(cmd, capture_output=True, text=True,
timeout=self._upload_timeout(file_path))
except subprocess.TimeoutExpired:
raise RuntimeError("fsend.me upload timed out")
url = r.stdout.strip()
if not url.startswith("http"):
raise RuntimeError(f"fsend.me bad response: {r.stdout[:200]}")
return UploadResult(url=url, service="fsend.me",
expires_in=f"{max_days or 7} days")
def download(self, url: str, output_path: str) -> bool:
code, _, _ = self._curl(["-o", output_path, url])
return code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
class FarsEeService(BaseService):
"""fars.ee — pb/pastebin fork, content-addressed (SHA1-keyed) storage.
API: POST https://fars.ee/ with multipart field `c=<file>`.
Response is NOT JSON — it's a line-separated key:value text:
date: <iso8601>
digest: <sha1 of file>
long: <base64 long id>
short: <short id>
size: <bytes>
status: <created|already exists|expired>
url: https://fars.ee/<short>.bin
uuid: <uuid>
Use ?u=1 query param to get URL-only response (single line).
Optional fields: p=1 (private, uses long URL), sunset=<seconds> (self-destruct).
Append .<ext> to URL for proper mimetype hint.
Server explicitly warns: "Please do NOT post large files" — so keep <=10MB.
"""
name = "fars.ee"
max_size_mb = 10
default_expiry = "unknown"
_API = "https://fars.ee/"
def upload(self, file_path: str, **kwargs) -> UploadResult:
# Build form fields. Field name is "c", not "file".
args = ["-F", f"c=@{file_path}"]
# Sunset (self-destruct) in seconds
sunset = kwargs.get("sunset_seconds", "")
if sunset:
args += ["-F", f"sunset={sunset}"]
# Private paste flag
if kwargs.get("private"):
args += ["-F", "p=1"]
# ?u=1 returns URL only, simpler to parse
url_only = "1"
code, out, err = self._curl(args + [f"{self._API}?u={url_only}"])
if code != 0:
raise RuntimeError(f"fars.ee upload failed: {err}")
url = out.strip()
if not url.startswith("http"):
# fars.ee is content-addressed (SHA1) — if the same file was already
# uploaded, the server returns just the status line without the
# URL. The file is still retrievable, but the server won't tell us
# where. The caller can retry with different content if they need
# a fresh URL; the service itself doesn't try to recover the URL
# because the server has no digest-lookup API.
raise RuntimeError(
f"fars.ee: {url!r} (file already uploaded to fars.ee with this "
f"exact content; no way to recover the existing URL. Use a "
f"different file or add a unique suffix.)"
)
return UploadResult(url=url, service="fars.ee",
expires_in=f"{sunset}s" if sunset else "unknown")
def download(self, url: str, output_path: str) -> bool:
# fars.ee serves the file directly at the URL
code, _, _ = self._curl(["-o", output_path, url])
return code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
class TmpfileLinkService(BaseService):
"""tmpfile.link — Cloudflare Workers-backed temp file host, no auth, 100MB.
API: POST https://tmpfile.link/api/upload with multipart field `file=@...`.
Response JSON: {"fileName": ..., "downloadLink": "https://d1-d10.tfdl.net/...",
"downloadLinkEncoded": ..., "size": ..., "type": ...}.
"Safe" types (images, docs) are served from `d.tmpfile.link`; "unsafe" types
(archives, binaries) are served from `d1-d10.tfdl.net`. Both hostnames serve
the raw file at the URL. 7-day auto-deletion for anonymous uploads; no
client-controllable expiry (expiry is server-side fixed). 100MB max.
"""
name = "tmpfile.link"
max_size_mb = 100
default_expiry = "7 days"
_API = "https://tmpfile.link/api/upload"
def upload(self, file_path: str, **kwargs) -> UploadResult:
code, out, err = self._curl(["-F", f"file=@{file_path}", self._API])
if code != 0:
raise RuntimeError(f"tmpfile.link upload failed: {err}")
try:
resp = json.loads(out)
except json.JSONDecodeError:
raise RuntimeError(f"tmpfile.link bad JSON: {out[:200]}")
url = resp.get("downloadLink", "")
if not url.startswith("http"):
raise RuntimeError(f"tmpfile.link: no downloadLink in response: {resp}")
return UploadResult(url=url, service="tmpfile.link",
expires_in="7 days",
file_id=resp.get("fileName", ""))
def download(self, url: str, output_path: str) -> bool:
code, _, _ = self._curl(["-o", output_path, url])
return code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
class PasteRsService(BaseService):
"""paste.rs — minimal text-only paste service, 4MB cap, no auth.
API: `POST https://paste.rs/` with the raw text as the request body
(NOT multipart/form-data). Server returns the URL directly, e.g.
`https://paste.rs/AEZu7`. GET on the URL returns the text as-is.
This is the modern replacement for termbin (which is firewalled from
most residential / cloud IPs as of mid-2026). Marked text-only because
the server treats the body as UTF-8 text — uploading a binary file
will technically work for raw bytes but the URL is intended for
sharing text snippets, logs, code, etc.
"""
name = "paste.rs"
max_size_mb = 4
default_expiry = "unknown (text only)"
_API = "https://paste.rs/"
def upload(self, file_path: str, **kwargs) -> UploadResult:
size = os.path.getsize(file_path)
if size > self.max_size_mb * 1024 * 1024:
raise RuntimeError(
f"paste.rs: file too large ({size} bytes > {self.max_size_mb}MB). "
f"paste.rs is text-only with a 4MB cap."
)
# Raw body upload via curl --data-binary @file. We use a fresh
# subprocess here (not self._curl) because the body is the file
# itself, not a multipart field.
cmd = ["curl", "-sS", "--max-time", "60", "-X", "POST",
"--data-binary", f"@{file_path}", self._API]
try:
r = subprocess.run(cmd, capture_output=True, text=True, timeout=70)
except subprocess.TimeoutExpired:
raise RuntimeError("paste.rs upload timed out")
url = r.stdout.strip()
if not url.startswith("http"):
# Common failure: 413 (file too large) returns HTML
if "413" in (r.stderr or "") or "Request Entity Too Large" in r.stdout:
raise RuntimeError(
f"paste.rs: file exceeds server limit (~4MB). "
f"Response: {r.stdout[:200]}"
)
raise RuntimeError(f"paste.rs bad response: {r.stdout[:200]}")
return UploadResult(url=url, service="paste.rs", expires_in="unknown")
def download(self, url: str, output_path: str) -> bool:
# paste.rs serves the text directly at the URL
code, _, _ = self._curl(["-o", output_path, url])
return code == 0 and os.path.exists(output_path) and os.path.getsize(output_path) > 0
class JuiceboxService(BaseService):
"""box.juicey.dev — open-source temp file host, content-addressed, 2GB max.