Fossil SCM

Additional obfuscation of the javascript that runs to implement the anti-robot defense.

drh 2025-08-18 11:45 trunk
Commit 4c4bce351d974e5b628b8305ddac18c705ab06a88568e4e42bd3fa4ba8ca1823
1 file changed +16 -9
+16 -9
--- src/robot.c
+++ src/robot.c
@@ -38,11 +38,11 @@
3838
** Or, if valid proof-of-work is present as either a query parameter or
3939
** as a cookie, then return 0.
4040
*/
4141
static int robot_proofofwork(void){
4242
sqlite3_int64 tm;
43
- unsigned h1, h2;
43
+ unsigned h1, h2, p1, p2, p3, p4, p5, k2, k3;
4444
int k;
4545
const char *z;
4646
const char *az[2];
4747
4848
/* Construct a proof-of-work value based on the IP address of the
@@ -97,22 +97,22 @@
9797
style_header("Browser Verification");
9898
@ <h1 id="x1">Checking to see if you are a robot<span id="x2"></span></h1>
9999
@ <form method="GET" id="x6"><p>
100100
@ <span id="x3" style="visibility:hidden;">\
101101
@ Press <input type="submit" id="x5" value="Ok" focus> to continue</span>
102
- @ <span id="x7" style="visibility:hidden;">You appear to be a robot.</span></p>
102
+ @ <span id="x7" style="visibility:hidden;">You appear to be a robot.</span>\
103
+ @ </p>
103104
cgi_query_parameters_to_hidden();
104105
@ <input id="x4" type="hidden" name="proof" value="0">
105106
@ </form>
106107
@ <script nonce='%s(style_nonce())'>
107
- @ window.addEventListener('load',function(){
108
- @ function aaa(x){return document.getElementById(x);}
108
+ @ function aaa(x){return document.getElementById(x);}\
109109
@ function bbb(h,a){\
110110
@ aaa("x4").value=h;\
111111
@ if((a%%75)==0){\
112112
@ aaa("x2").textContent=aaa("x2").textContent+".";\
113
- @ }
113
+ @ }\
114114
@ if(a>0){\
115115
@ setTimeout(bbb,1,h+a,a-1);\
116116
@ }else if(window.getComputedStyle(document.body).zIndex==='0'){\
117117
@ aaa("x3").style.visibility="visible";\
118118
@ aaa("x2").textContent="";\
@@ -123,15 +123,22 @@
123123
@ aaa("x7").style.visibility="visible";\
124124
@ aaa("x2").textContent="";\
125125
@ aaa("x3").style.display="none";\
126126
@ aaa("x1").textContent="Access Denied";\
127127
@ }\
128
- @ }
128
+ @ }\
129129
k = 400 + h2%299;
130
- h2 = (k*k + k)/2;
131
- @ setTimeout(function(){bbb(%u(h1-h2),%u(k));},10);
132
- @ }, false);
130
+ k2 = (h2/299)%99 + 973;
131
+ k3 = (h2/(299*99))%99 + 811;
132
+ p1 = (k*k + k)/2;
133
+ p2 = h1-p1;
134
+ p3 = p2%k2;
135
+ p4 = (p2/k2)%k3;
136
+ p5 = p2/(k2*k3);
137
+ @ function ccc(a,b,c){return (a*%u(k3)+b)*%u(k2)+c;}\
138
+ @ window.addEventListener('load',function(){\
139
+ @ bbb(ccc(%u(p5),%u(p4),%u(p3)),%u(k));},false);
133140
@ </script>
134141
style_finish_page();
135142
return 1;
136143
}
137144
138145
--- src/robot.c
+++ src/robot.c
@@ -38,11 +38,11 @@
38 ** Or, if valid proof-of-work is present as either a query parameter or
39 ** as a cookie, then return 0.
40 */
41 static int robot_proofofwork(void){
42 sqlite3_int64 tm;
43 unsigned h1, h2;
44 int k;
45 const char *z;
46 const char *az[2];
47
48 /* Construct a proof-of-work value based on the IP address of the
@@ -97,22 +97,22 @@
97 style_header("Browser Verification");
98 @ <h1 id="x1">Checking to see if you are a robot<span id="x2"></span></h1>
99 @ <form method="GET" id="x6"><p>
100 @ <span id="x3" style="visibility:hidden;">\
101 @ Press <input type="submit" id="x5" value="Ok" focus> to continue</span>
102 @ <span id="x7" style="visibility:hidden;">You appear to be a robot.</span></p>
 
103 cgi_query_parameters_to_hidden();
104 @ <input id="x4" type="hidden" name="proof" value="0">
105 @ </form>
106 @ <script nonce='%s(style_nonce())'>
107 @ window.addEventListener('load',function(){
108 @ function aaa(x){return document.getElementById(x);}
109 @ function bbb(h,a){\
110 @ aaa("x4").value=h;\
111 @ if((a%%75)==0){\
112 @ aaa("x2").textContent=aaa("x2").textContent+".";\
113 @ }
114 @ if(a>0){\
115 @ setTimeout(bbb,1,h+a,a-1);\
116 @ }else if(window.getComputedStyle(document.body).zIndex==='0'){\
117 @ aaa("x3").style.visibility="visible";\
118 @ aaa("x2").textContent="";\
@@ -123,15 +123,22 @@
123 @ aaa("x7").style.visibility="visible";\
124 @ aaa("x2").textContent="";\
125 @ aaa("x3").style.display="none";\
126 @ aaa("x1").textContent="Access Denied";\
127 @ }\
128 @ }
129 k = 400 + h2%299;
130 h2 = (k*k + k)/2;
131 @ setTimeout(function(){bbb(%u(h1-h2),%u(k));},10);
132 @ }, false);
 
 
 
 
 
 
 
133 @ </script>
134 style_finish_page();
135 return 1;
136 }
137
138
--- src/robot.c
+++ src/robot.c
@@ -38,11 +38,11 @@
38 ** Or, if valid proof-of-work is present as either a query parameter or
39 ** as a cookie, then return 0.
40 */
41 static int robot_proofofwork(void){
42 sqlite3_int64 tm;
43 unsigned h1, h2, p1, p2, p3, p4, p5, k2, k3;
44 int k;
45 const char *z;
46 const char *az[2];
47
48 /* Construct a proof-of-work value based on the IP address of the
@@ -97,22 +97,22 @@
97 style_header("Browser Verification");
98 @ <h1 id="x1">Checking to see if you are a robot<span id="x2"></span></h1>
99 @ <form method="GET" id="x6"><p>
100 @ <span id="x3" style="visibility:hidden;">\
101 @ Press <input type="submit" id="x5" value="Ok" focus> to continue</span>
102 @ <span id="x7" style="visibility:hidden;">You appear to be a robot.</span>\
103 @ </p>
104 cgi_query_parameters_to_hidden();
105 @ <input id="x4" type="hidden" name="proof" value="0">
106 @ </form>
107 @ <script nonce='%s(style_nonce())'>
108 @ function aaa(x){return document.getElementById(x);}\
 
109 @ function bbb(h,a){\
110 @ aaa("x4").value=h;\
111 @ if((a%%75)==0){\
112 @ aaa("x2").textContent=aaa("x2").textContent+".";\
113 @ }\
114 @ if(a>0){\
115 @ setTimeout(bbb,1,h+a,a-1);\
116 @ }else if(window.getComputedStyle(document.body).zIndex==='0'){\
117 @ aaa("x3").style.visibility="visible";\
118 @ aaa("x2").textContent="";\
@@ -123,15 +123,22 @@
123 @ aaa("x7").style.visibility="visible";\
124 @ aaa("x2").textContent="";\
125 @ aaa("x3").style.display="none";\
126 @ aaa("x1").textContent="Access Denied";\
127 @ }\
128 @ }\
129 k = 400 + h2%299;
130 k2 = (h2/299)%99 + 973;
131 k3 = (h2/(299*99))%99 + 811;
132 p1 = (k*k + k)/2;
133 p2 = h1-p1;
134 p3 = p2%k2;
135 p4 = (p2/k2)%k3;
136 p5 = p2/(k2*k3);
137 @ function ccc(a,b,c){return (a*%u(k3)+b)*%u(k2)+c;}\
138 @ window.addEventListener('load',function(){\
139 @ bbb(ccc(%u(p5),%u(p4),%u(p3)),%u(k));},false);
140 @ </script>
141 style_finish_page();
142 return 1;
143 }
144
145

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button