Skip to content
This repository was archived by the owner on Jun 26, 2025. It is now read-only.

Commit 9b9687b

Browse files
committed
new payloads
1 parent a5f98d1 commit 9b9687b

File tree

8 files changed

+435
-145
lines changed

8 files changed

+435
-145
lines changed

.idea/.name

Lines changed: 0 additions & 1 deletion
This file was deleted.

.idea/artifacts/WebCorrupter_js_js_1_0_SNAPSHOT.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 136 additions & 96 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@file:Suppress("NOTHING_TO_INLINE")
2+
package ru.morozovit.util
3+
4+
import org.w3c.dom.events.Event
5+
import org.w3c.dom.events.EventTarget
6+
import kotlin.random.Random
7+
8+
inline fun EventTarget.addEventListener(type: String, crossinline listener: (Event) -> Unit) {
9+
addEventListener(type, { listener(it) }, null)
10+
}
11+
12+
inline fun Random.nextHexColor() =
13+
"#" +
14+
(1..6)
15+
.map {
16+
"0123456789ABCDEF"[Random.nextInt(16)]
17+
}
18+
.joinToString("")
19+
20+
inline fun nextHexColor() = Random.nextHexColor()

src/jsMain/kotlin/ru/morozovit/webcorrupter/Main.kt

Lines changed: 135 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,33 @@ import kotlinx.browser.window
55
import kotlinx.coroutines.*
66
import kotlinx.dom.addClass
77
import org.w3c.dom.*
8+
import ru.morozovit.util.addEventListener
9+
import ru.morozovit.util.nextHexColor
10+
import ru.morozovit.webcorrupter.RandomUtils.randomDelay
811
import kotlin.random.Random.Default.nextInt
12+
import kotlin.random.Random.Default.nextLong
913

1014
object RandomUtils {
11-
fun randomNumber(min: Int, max: Int): Int = nextInt(min, max + 1)
15+
suspend inline fun randomDelay() = delay(nextLong(50, 3000))
16+
}
1217

13-
fun randomColor(): String {
14-
val letters = "0123456789ABCDEF"
15-
return "#" + (1..6).map { letters[nextInt(16)] }.joinToString("")
18+
object Virus {
19+
private val max get() = when {
20+
document.body!!.innerHTML.length > 500000 -> 1000
21+
document.body!!.innerHTML.length > 100000 -> 400
22+
document.body!!.innerHTML.length > 50000 -> 300
23+
document.body!!.innerHTML.length > 10000 -> 200
24+
document.body!!.innerHTML.length > 5000 -> 100
25+
else -> 50
1626
}
17-
}
1827

19-
object Corrupter {
20-
object Payloads {
21-
private fun max(): Int = when {
22-
document.body!!.innerHTML.length > 100000 -> 400
23-
document.body!!.innerHTML.length > 50000 -> 300
24-
document.body!!.innerHTML.length > 10000 -> 200
25-
document.body!!.innerHTML.length > 5000 -> 100
26-
else -> 1000
27-
}
28+
private fun randomNumberOfTimes() = nextInt(10, max)
2829

30+
object Payloads {
2931
suspend fun messUpElements() {
30-
delay(nextInt(100, 3000).toLong())
32+
randomDelay()
3133
console.log("Messing up elements...")
32-
val numberOfTimes = RandomUtils.randomNumber(10, max())
34+
val numberOfTimes = randomNumberOfTimes()
3335
console.log("Number of times: ", numberOfTimes)
3436
repeat(numberOfTimes) {
3537
try {
@@ -40,9 +42,9 @@ object Corrupter {
4042
}
4143

4244
suspend fun addRandomText() {
43-
delay(nextInt(100, max()).toLong())
45+
randomDelay()
4446
console.log("Adding random text...")
45-
val numberOfTimes = RandomUtils.randomNumber(10, max())
47+
val numberOfTimes = randomNumberOfTimes()
4648
console.log("Number of times: ", numberOfTimes)
4749
repeat(numberOfTimes) {
4850
try {
@@ -55,31 +57,97 @@ object Corrupter {
5557
suspend fun addRandomStyles() {
5658
delay(nextInt(100, 3000).toLong())
5759
console.log("Adding random styles...")
58-
val numberOfTimes = RandomUtils.randomNumber(10, max())
60+
val numberOfTimes = randomNumberOfTimes()
5961
console.log(numberOfTimes)
6062
repeat(numberOfTimes) {
6163
try {
6264
val element = randomElement() as HTMLElement
63-
when (RandomUtils.randomNumber(0, 2)) {
64-
0 -> element.style.color = RandomUtils.randomColor()
65-
1 -> element.style.backgroundColor = RandomUtils.randomColor()
66-
2 -> element.style.transform = "blur(${RandomUtils.randomNumber(1, 100)}px)"
65+
when (nextInt(0, 2)) {
66+
0 -> element.style.color = nextHexColor()
67+
1 -> element.style.backgroundColor = nextHexColor()
68+
2 -> element.style.transform = "blur(${nextInt(1, 100)}px)"
6769
}
6870
} catch (_: Exception) {}
6971
delay(nextInt(100, 1000).toLong())
7072
}
7173
}
7274

73-
fun showHead() {
75+
@Suppress("RedundantSuspendModifier")
76+
suspend fun showHead() {
7477
document.head?.addClass("show")
7578
}
7679

7780
suspend fun randomScroll() {
7881
while (true) {
79-
window.scrollTo(0.0, RandomUtils.randomNumber(0, window.innerHeight).toDouble())
82+
window.scrollTo(0.0, nextInt(0, window.innerHeight).toDouble())
8083
delay(nextInt(100, 10000).toLong())
8184
}
8285
}
86+
87+
suspend fun invertColors() {
88+
randomDelay()
89+
console.log("Inverting colors...")
90+
document.body?.style?.filter = "invert(100%)"
91+
delay(nextInt(3000, 10000).toLong())
92+
document.body?.style?.filter = "none"
93+
}
94+
95+
suspend fun shakeElements() {
96+
randomDelay()
97+
console.log("Shaking elements...")
98+
val numberOfTimes = randomNumberOfTimes()
99+
repeat(numberOfTimes) {
100+
try {
101+
val element = randomElement() as HTMLElement
102+
element.style.animation = "shake 0.5s"
103+
element.style.animationIterationCount = "infinite"
104+
} catch (_: Exception) {}
105+
delay(nextInt(100, 1000).toLong())
106+
}
107+
}
108+
109+
suspend fun rotateElements() {
110+
randomDelay()
111+
console.log("Rotating elements...")
112+
val numberOfTimes = randomNumberOfTimes()
113+
repeat(numberOfTimes) {
114+
try {
115+
val element = randomElement() as HTMLElement
116+
element.style.transform = "rotate(${nextInt(0, 360)}deg)"
117+
} catch (_: Exception) {}
118+
delay(nextInt(100, 1000).toLong())
119+
}
120+
}
121+
122+
suspend fun showBSOD() {
123+
randomDelay()
124+
console.log("Showing BSOD...")
125+
document.documentElement!!.innerHTML = """
126+
|<head>
127+
|</head>
128+
|<body>
129+
|<pre id="bsod">
130+
|A problem has been detected and <!-- TODO random chars --> has been shut down to prevent damage
131+
|to your computer.
132+
|
133+
|BUGCODE_USB_DRIVE
134+
|
135+
|If this is the first time you've seen this Stop error screen,
136+
|restart your computer. If this screen appears again, follow these steps:
137+
|
138+
|Throw your computer out of the window, go outside, touch grass, and the problem
139+
|will fix itself.
140+
|
141+
|If problems continue, you have nothing to do. Just throw it out of the window.
142+
|
143+
|Technical Information:
144+
|
145+
|*** STOP: <!-- rnd hex number --> (<!-- rnd hex number -->, <!-- rnd hex number -->, <!-- rnd hex number -->, <!-- rnd hex number -->)
146+
|</pre>
147+
|</body>
148+
""".trimMargin()
149+
throw RuntimeException("BSOD displayed")
150+
}
83151
}
84152

85153
private fun randomElement(fromBody: Boolean = false): Element {
@@ -88,30 +156,55 @@ object Corrupter {
88156
} else {
89157
document.querySelectorAll("*")
90158
}
91-
return elements[RandomUtils.randomNumber(0, elements.length - 1)] as Element
159+
return elements[nextInt(0, elements.length)] as Element
160+
}
161+
162+
@OptIn(DelicateCoroutinesApi::class)
163+
fun start() {
164+
GlobalScope.launch {
165+
while (true) {
166+
try {
167+
run()
168+
break
169+
} catch (e: Exception) {
170+
console.error(e)
171+
Payloads.showBSOD()
172+
}
173+
}
174+
}
92175
}
93176

94177
@OptIn(DelicateCoroutinesApi::class)
95-
suspend fun start() {
178+
suspend fun run() {
96179
loadStyle()
97180
showCheatActivated()
98-
Payloads.messUpElements()
99-
if (RandomUtils.randomNumber(0, 1) == 1) {
181+
val payloads = listOf(
182+
Payloads::messUpElements,
183+
Payloads::addRandomText,
184+
Payloads::addRandomStyles,
185+
Payloads::invertColors,
186+
Payloads::shakeElements,
187+
Payloads::rotateElements,
188+
Payloads::showHead
189+
).shuffled()
190+
191+
for (payload in payloads) {
192+
payload()
193+
}
194+
195+
if (nextInt(0, 1) == 1) {
100196
Payloads.showHead()
101197
}
102-
if (RandomUtils.randomNumber(0, 1) == 1) {
198+
if (nextInt(0, 1) == 1) {
103199
GlobalScope.launch { Payloads.randomScroll() }
104200
}
105-
if (RandomUtils.randomNumber(0, 1) == 1) {
106-
Payloads.addRandomText()
107-
}
108-
if (RandomUtils.randomNumber(0, 1) == 1) {
109-
Payloads.addRandomStyles()
110-
}
201+
202+
// Show BSOD at the end
203+
Payloads.showBSOD()
111204
}
112205

113206
private suspend fun loadStyle() {
114-
val style = window.fetch("https://raw.githubusercontent.com/denis0001-dev/WebCorrupter.js/main/style.css").await()
207+
val style = window.fetch("https://raw.githubusercontent.com/denis0001-dev/WebCorrupter.js/main/dist/style.css").await()
115208
val stylesheet = document.createElement("style") as HTMLStyleElement
116209
stylesheet.textContent = style.text().await()
117210
document.head?.appendChild(stylesheet)
@@ -133,11 +226,12 @@ object Corrupter {
133226
}
134227
}
135228

136-
@OptIn(DelicateCoroutinesApi::class)
137229
fun main() {
138230
if (document.readyState == DocumentReadyState.COMPLETE) {
139-
GlobalScope.launch { Corrupter.start() }
231+
Virus.start()
140232
} else {
141-
document.addEventListener("DOMContentLoaded", { GlobalScope.launch { Corrupter.start() } })
233+
document.addEventListener("DOMContentLoaded") {
234+
Virus.start()
235+
}
142236
}
143-
}
237+
}

0 commit comments

Comments
 (0)