Skip to content

Commit a2601fd

Browse files
committed
chpw ratelimit
1 parent 025942a commit a2601fd

File tree

5 files changed

+5
-1
lines changed

5 files changed

+5
-1
lines changed

copyparty/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,7 @@ def add_safety(ap):
13361336
ap2.add_argument("--no-robots", action="store_true", help="adds http and html headers asking search engines to not index anything (volflag=norobots)")
13371337
ap2.add_argument("--logout", metavar="H", type=float, default=8086.0, help="logout clients after \033[33mH\033[0m hours of inactivity; [\033[32m0.0028\033[0m]=10sec, [\033[32m0.1\033[0m]=6min, [\033[32m24\033[0m]=day, [\033[32m168\033[0m]=week, [\033[32m720\033[0m]=month, [\033[32m8760\033[0m]=year)")
13381338
ap2.add_argument("--ban-pw", metavar="N,W,B", type=u, default="9,60,1440", help="more than \033[33mN\033[0m wrong passwords in \033[33mW\033[0m minutes = ban for \033[33mB\033[0m minutes; disable with [\033[32mno\033[0m]")
1339+
ap2.add_argument("--ban-pwc", metavar="N,W,B", type=u, default="5,60,1440", help="more than \033[33mN\033[0m password-changes in \033[33mW\033[0m minutes = ban for \033[33mB\033[0m minutes; disable with [\033[32mno\033[0m]")
13391340
ap2.add_argument("--ban-404", metavar="N,W,B", type=u, default="50,60,1440", help="hitting more than \033[33mN\033[0m 404's in \033[33mW\033[0m minutes = ban for \033[33mB\033[0m minutes; only affects users who cannot see directory listings because their access is either g/G/h")
13401341
ap2.add_argument("--ban-403", metavar="N,W,B", type=u, default="9,2,1440", help="hitting more than \033[33mN\033[0m 403's in \033[33mW\033[0m minutes = ban for \033[33mB\033[0m minutes; [\033[32m1440\033[0m]=day, [\033[32m10080\033[0m]=week, [\033[32m43200\033[0m]=month")
13411342
ap2.add_argument("--ban-422", metavar="N,W,B", type=u, default="9,2,1440", help="hitting more than \033[33mN\033[0m 422's in \033[33mW\033[0m minutes = ban for \033[33mB\033[0m minutes (invalid requests, attempted exploits ++)")

copyparty/httpcli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2912,6 +2912,7 @@ def handle_chpw(self) -> bool:
29122912

29132913
ok, msg = self.asrv.chpw(self.conn.hsrv.broker, self.uname, pwd)
29142914
if ok:
2915+
self.cbonk(self.conn.hsrv.gpwc, pwd, "pw", "too many password changes")
29152916
ok, msg = self.get_pwd_cookie(pwd)
29162917
if ok:
29172918
msg = "new password OK"

copyparty/httpsrv.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ def __init__(self, broker: "BrokerCli", nid: Optional[int]) -> None:
123123
self.nm = NetMap([], [])
124124
self.ssdp: Optional["SSDPr"] = None
125125
self.gpwd = Garda(self.args.ban_pw)
126+
self.gpwc = Garda(self.args.ban_pwc)
126127
self.g404 = Garda(self.args.ban_404)
127128
self.g403 = Garda(self.args.ban_403)
128129
self.g422 = Garda(self.args.ban_422, False)

copyparty/svchub.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def __init__(
168168
# for non-http clients (ftp, tftp)
169169
self.bans: dict[str, int] = {}
170170
self.gpwd = Garda(self.args.ban_pw)
171+
self.gpwc = Garda(self.args.ban_pwc)
171172
self.g404 = Garda(self.args.ban_404)
172173
self.g403 = Garda(self.args.ban_403)
173174
self.g422 = Garda(self.args.ban_422, False)

tests/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def __init__(self, a=None, v=None, c=None, **ka0):
164164
ex = "ah_alg bname chmod_f chpw_db doctitle df exit favico idp_h_usr ipa html_head lg_sba lg_sbf log_fk md_sba md_sbf name og_desc og_site og_th og_title og_title_a og_title_v og_title_i shr tcolor textfiles unlist vname xff_src zipmaxt R RS SR"
165165
ka.update(**{k: "" for k in ex.split()})
166166

167-
ex = "ban_403 ban_404 ban_422 ban_pw ban_url spinner"
167+
ex = "ban_403 ban_404 ban_422 ban_pw ban_pwc ban_url spinner"
168168
ka.update(**{k: "no" for k in ex.split()})
169169

170170
ex = "ext_th grp on403 on404 xac xad xar xau xban xbc xbd xbr xbu xiu xm"

0 commit comments

Comments
 (0)