├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── ROADMAP.md ├── devices.php ├── functions.php ├── log.php ├── make_telnet_rd.php └── resources ├── etc ├── hosts ├── hosts.allow ├── inetd.conf ├── networks ├── profile ├── protocols ├── screenrc ├── services └── ttys └── restored_external.c /.gitignore: -------------------------------------------------------------------------------- 1 | WD_* 2 | .DS_Store 3 | bin/ 4 | dependencies/ 5 | *.shsh* 6 | *.der 7 | .cache/ 8 | *bootrd*.sh 9 | debs/ 10 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "PyBoot"] 2 | path = PyBoot 3 | url = https://github.com/MatthewPierson/PyBoot.git 4 | [submodule "CFPropertyList"] 5 | path = CFPropertyList 6 | url = https://github.com/arx8x/CFPropertyList 7 | -------------------------------------------------------------------------------- /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 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # telnetd_ramdisk 2 | 3 | #### Notice: I've gotten a job and don't have any focus left for this project. I've heard about [ramiel](https://ramiel.app/) which is supposed to work better. Thanks to everyone who used this and contributed, I could never have imagined it to become this popular :) You can of course still give this a try but beware that I'll probably not be able to help you. 4 | 5 | ### An automatic telnet ramdisk creator 6 | 7 | Remember [ssh_rd by msftguy](https://github.com/msftguy/ssh-rd)? You could simply run it and get a remote shell running on a ramdisk on your iDevice. I built a jailbreak with it. (And opensn0w). 8 | This is the same thing, reloaded. I couldn't get sshd to work, so it uses inetd with telnetd instead. If you check the code there's an easy way to add whatever .deb you like by rerunning the apt-download command and pasting the result in the code. (Search the code for `apt download`) 9 | 10 | ## Usage 11 | 12 | To download/install: 13 | 14 | `git clone https://github.com/danieltroger/telnetd_ramdisk.git --recursive` 15 | 16 | ``` 17 | OPTIONS: 18 | -d Device identifier (example: iPhone10,4) 19 | -b Boardconfig (example: d201ap) 20 | -v iOS version to use as base for ramdisk 21 | -s shsh2 file (can be any version) 22 | -h print this help text 23 | 24 | ``` 25 | 26 | 27 | Example: `./make_telnet_rd.php -d iPhone10,5 -b D211AP -v 13.5 -s /Users/daniel/Documents/dualbootfun/4905935052021678_iPhone10\,5_d211ap_13.7-17H35_27325c8258be46e69d9ee57fa9a8fbc28b873df434e5e702a8b27999551138ae.shsh2` 28 | 29 | To boot a previously created ramdisk, use the ./bootrd*.sh scripts 30 | 31 | It will open port 23 on the device once it's booted which you need to "proxy" over usb with iproxy 32 | Just follow the instructions of the script :) 33 | 34 | To enter dfu mode [look here](https://www.theiphonewiki.com/wiki/DFU_Mode) or use [checkra1n](https://checkra.in/) and QUIT IT ASAP as soon as it says "successfully entered dfu mode" 35 | 36 | #### More info 37 | For getting the .shsh2 files I can recommend [shsh.host](https://shsh.host). The version of the blobs *DON'T MATTER*, they just have to be for the correct device (ECID). So you can boot a 13.0 ramdisk with 13.7 blobs. 38 | 39 | it tells you everything you need to know and do to get the ramdisk and telnet connection up and running. PyBoot is used for booting, so the supported devices (as of now) are: 40 | * iPhone 5s 41 | * iPhone 6/6+ 42 | * iPhone 6s/6s+ 43 | * iPhone SE (First Gen) 44 | * iPhone 7/7+ 45 | * iPhone 8/8+ 46 | * iPhone X 47 | 48 | Supported operating systems: macOS 49 | 50 | Regarding iOS versions your mileage may vary. I have successfully tested iOS 12.0, 12.4.1, 13.0, 13.5, 13.6, 13.7, 14.0. 51 | 52 | BTW: the whole script is made to be ran again and again. Cancelled half way? Run it again and it will pick up where it left. Made changes to ramdisk.dmg? Run it again and answer yes. Made changes to restored_external.c? Run it again! Don't be afraid 53 | 54 | 55 | The script is based on [this guide](https://dualbootfun.github.io/) and roughly does this: 56 | 1. Checks for dependencies 57 | 2. Downloads ipsw 58 | 3. Extracts ipsw 59 | 4. Identifies trustcache/ramdisk names by mounting all dmgs and keeping the name of the one with the correct partition name 60 | 5. Downloads and patches iBSS, iBEC and kernelcache, signs them + trustcache & devicetree 61 | 6. Downloads .debs to install into the ramdisk 62 | 7. Extracts those debs to a staging area 63 | 8. Syncs the staging area into the ramdisk which it mounts (this is done to preserve symlinks and not override what exists) 64 | 9. Adds inetd and other config files to /etc 65 | 10. Compiles and signs a binary which will start telnetd and attempt to mount the rootfs and data fs with seputil 66 | 11. Downloads pyboot in case you didn't clone this repo recursively 67 | 12. Writes a shell script to boot with pyboot and load all needed files 68 | 69 | You can then execute that script by running `./boot_rd_VERSION.sh` with VERSION being the ios version 70 | 71 | ### What's expected to happen? 72 | - the script will output the output of all its sub-utilities. Read it, in case some errors out. 73 | - when running bootrd.sh: 74 | - PyBoot should say "exploit worked", at least for A11 devices if everything went right 75 | - irecovery should show a total of six progress bars, and while they load the backlight should turn on and off on non OLED devices 76 | - after all 6 progress bars have loaded you should see a verbose boot on the device's screen 77 | - read the verbose boot output, especially at the end, for hints of errors 78 | - after the verbose boot the screen should turn white with a progress bar under an apple logo which never completes. At this point (or like 10s after) you can start iproxy if you haven't already and try to connect via telnet 79 | - after around a minute the screen will turn black but you should still have access to the device 80 | 81 | 82 | #### Dependencies: 83 | img4lib, img4tool, ldid2, autodecrypt, kairos, libusbmuxd, Kernel64Patcher, libirecovery and tools preinstalled on macOS (like php, curl, zip, plutil, hdiutil, etc). If you just run the script without them it will give you the github URLs to install them from. 84 | 85 | 86 | ------- 87 | 88 | # Credits 89 | 90 | * @arx8x for his contributions of bug fixes, improvements and a big speed up to the project and [his fork](https://github.com/arx8x/telnetd_ramdisk) which I shamelessly merged into my repo 91 | * Huge thanks to [mcg29](https://github.com/mcg29), without his help and info I would have given up a long time ago. [twitter](https://twitter.com/mcg29_) 92 | * Also a big thanks to [Exploit3d](https://twitter.com/exploit3dguy) for the info about the seputil commands, mounting the user fs would have been hard without his help. 93 | * Thanks to [Sam Bingner](https://github.com/sbingner) for the inetutils package, we wouldn't have telnetd on iOS without him. Also he inspired me to write script this by asking for it. [twitter](https://twitter.com/sbingner) 94 | * Thanks to [@MatthewPierson](https://github.com/MatthewPierson) for PyBoot and [@axi0mX](https://github.com/axi0mX) for [ipwndfu](https://github.com/axi0mX/ipwndfu)/checkm8 I'm illiterate in low-level stuff so all the peeps making this "a bunch of shell commands" are incredible. Thank you <3! 95 | * Thanks to the writers of my dependencies: 96 | * [@xerub](https://github.com/xerub) for img4lib 97 | * [@dayt0n](https://github.com/dayt0n) for kairos 98 | * [@nikias](https://github.com/nikias) / [@libimobiledevice](https://github.com/libimobiledevice) for iproxy and libirecovery 99 | * Thanks to [@Ralph0045](https://github.com/Ralph0045) for Kernel64Patcher 100 | * And thanks to whoever I might have forgotten 101 | 102 | the script is licensed under GPLv3 103 | -------------------------------------------------------------------------------- /ROADMAP.md: -------------------------------------------------------------------------------- 1 | - [x] use partialzip instead of downloading the whole IPSW file 2 | - [x] build dependencies into bin/ automatically 3 | - [x] make binary paths dynamic 4 | - [x] make arguments optional 5 | - [x] if device info isn't provided, read DFU device with irecovery 6 | - [x] implement ipsw.me API handler to recognize device and get fw url 7 | - [x] handle deb folder in script directory since it doesn't need to be re-downloaded for other device+version combinations 8 | - [ ] if no shsh2 is provided, get an apticket using tsschecker(if installed) or with shsh.host api 9 | - [ ] download() function for all downloads (handle wget/curl dependencies within it) 10 | - [x] CFPropertyList library to read buildmanifest and properly identify images 11 | - [ ] better logging 12 | - [ ] debian parser to parse repositories and download debs by package identifier and version 13 | - [ ] fix patching A9? 14 | -------------------------------------------------------------------------------- /devices.php: -------------------------------------------------------------------------------- 1 | 184 | -------------------------------------------------------------------------------- /functions.php: -------------------------------------------------------------------------------- 1 | url for cURL, param2 -> pass array to be used as header 8 | $handle = curl_init(); 9 | curl_setopt($handle, CURLOPT_URL, $url); 10 | if(isset($headers)) curl_setopt($handle, CURLOPT_HTTPHEADER, $headers) ; 11 | if(!empty($post)) curl_setopt($handle, CURLOPT_POSTFIELDS, $post); 12 | if(!empty($opt_arr)) curl_setopt_array($handle, $opt_arr); 13 | 14 | curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true); 15 | curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false); 16 | curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false); 17 | curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1); 18 | curl_error($handle); 19 | $response = curl_exec($handle); 20 | curl_close($handle); 21 | 22 | $json = json_decode(trim($response)); 23 | return (is_object($json) ? $json : $response); 24 | } 25 | 26 | function print_usage() 27 | { 28 | global $argv, $options; 29 | echo("Telnetd Ramdisk\n"); 30 | echo("Lets you boot your device with a ramdisk and connect to it using telnet\n\n"); 31 | echo("OPTIONS:\n"); 32 | foreach($options as $opt_short => $option) 33 | { 34 | echo(" -$opt_short\t{$option['help']}\n"); 35 | } 36 | echo("\nExample: php {$argv[0]} -d iPhone10,6 -b D221AP -v 13.0 -s 13.0.shsh2\n"); 37 | echo("shsh2 file can be from any version but needs to be from your device (ecid). Use: https://shsh.host/\n"); 38 | echo("if device parameters aren't specified, the program will attempt to detect DFU devices attached to this machine\n\n"); 39 | } 40 | 41 | function ask($question){ 42 | echo("\e[1m\x1B[31m{$question}\e[0m\e[0m\n"); 43 | $h = fopen("php://stdin","r"); 44 | $answer = fgets($h); 45 | fclose($h); 46 | return ($answer === "y" . PHP_EOL || $answer === "yes" . PHP_EOL); 47 | } 48 | 49 | function mount_rd(){ 50 | Log::writeVerboseInfo("Mounting ramdisk.dmg"); 51 | $try_mount = execute("hdiutil attach ramdisk.dmg 2>&1",1); 52 | $mount_point = explode(" ",preg_replace('/\s+/', ' ', $try_mount)); 53 | unset($mount_point[0]); 54 | unset($mount_point[sizeof($mount_point)]); 55 | $mount_point = implode(" ",$mount_point); 56 | return $mount_point; 57 | } 58 | 59 | function unmount($mountpoint){ 60 | return execute("hdiutil detach \"{$mountpoint}\" 2>&1",1); 61 | } 62 | 63 | function detect_device(): ?object 64 | { 65 | $device_properties = array(); 66 | $command = "irecovery -q"; 67 | $stdout = execute($command, true); 68 | if(preg_match_all("/(.+?)\:.\s*(?:(0x[0-9a-f]+)|(.+))\n/i", $stdout, $matches)) 69 | { 70 | foreach($matches[1] as $index => $match) 71 | { 72 | if(!empty($matches[2][$index])) 73 | { 74 | $number = hexdec(trim($matches[2][$index])); 75 | $device_properties[trim($match)] = $number; 76 | } 77 | else 78 | { 79 | $device_properties[trim($match)] = trim($matches[3][$index]); 80 | } 81 | } 82 | if(empty($device_properties['CPID']) || empty($device_properties['BDID'])) return null; 83 | $device = find_device($device_properties['CPID'], $device_properties['BDID']); 84 | if($device) 85 | { 86 | $device->ecid_raw = $device_properties['ECID']; 87 | $device->ecid = strtoupper(dechex($device_properties['ECID'])); 88 | return $device; 89 | } 90 | } 91 | return null; 92 | } 93 | 94 | function read_device(): ?object 95 | { 96 | if( !($device = detect_device()) ) 97 | { 98 | return null; 99 | } 100 | $device_text = "{$device->name} ({$device->identifier}) with boardConfig {$device->BoardConfig}\n"; 101 | $device_text .= "Is this the device you're making the ramdisk for?"; 102 | return (ask($device_text) ? $device : null); 103 | } 104 | 105 | function find_device(int $cpid, int $bdid): ?object 106 | { 107 | $fw = get_firmware_data(); 108 | // lookup in irecovery first 109 | $irecv_device = irecv_lookup_device($cpid, $bdid); 110 | if($irecv_device) 111 | { 112 | $identifier = $irecv_device[0]; 113 | if(isset($fw->devices->$identifier)) 114 | { 115 | $out_device = $fw->devices->$identifier; 116 | $out_device->BoardConfig = $irecv_device[1]; 117 | $out_device->cpid = $irecv_device[3]; 118 | $out_device->bdid = $irecv_device[2]; 119 | $out_device->identifier = $irecv_device[0]; 120 | return $out_device; 121 | } 122 | } 123 | foreach($fw->devices as $identifier => $device) 124 | { 125 | if( ($device->cpid === $cpid) && ($device->bdid === $bdid) ) 126 | { 127 | $device->identifier = $identifier; 128 | return $device; 129 | } 130 | } 131 | return null; 132 | } 133 | 134 | function execute($command, $show_output = false){ 135 | Log::writeVerboseInfo("Executing {$command}"); 136 | $h = popen($command . " 2>&1","r"); 137 | $o = ""; 138 | while (!feof($h)) { 139 | $b = fread($h,1024); 140 | $o .= $b; 141 | } 142 | Log::main()->writeLog($o, LOGTYPE_DEBUG, $show_output); 143 | fclose($h); 144 | return $o; 145 | } 146 | 147 | function get_firmware_data(bool $force_refresh = false): stdClass 148 | { 149 | $url = 'https://api.ipsw.me/v2.1/firmwares.json/condensed'; 150 | $cache_path = __DIR__ . "/.cache/"; 151 | $cache_file = $cache_path."firmwares.json"; 152 | if(!is_dir($cache_path)) mkdir($cache_path); 153 | if(!file_exists($cache_file)) $force_refresh = true; 154 | if($force_refresh) 155 | { 156 | execute("wget $url -O $cache_file"); 157 | } 158 | if(!file_exists($cache_file)) return null; 159 | $fw_data = file_get_contents($cache_file); 160 | $fw = json_decode($fw_data); 161 | unset($fw_data); 162 | return $fw; 163 | } 164 | 165 | function get_ipsw_url(string $device, string $version): ?string 166 | { 167 | Log::writeVerboseInfo("Getting ipsw url from ipsw.me API"); 168 | $fw = get_firmware_data(); 169 | if(!isset($fw->devices->$device)) return null; 170 | foreach($fw->devices->$device->firmwares as $firmware) 171 | { 172 | if($firmware->version == $version) 173 | { 174 | $url = $firmware->url; 175 | Log::writeInfo("Got url for version: $version"); 176 | return $url; 177 | } 178 | } 179 | Log::writeError("Couldn't get IPSW url for $version for $device"); 180 | return null; 181 | } 182 | 183 | function pls_install_msg($github_project){ 184 | return "Dependency missing: Please download, compile (if needed) and install {$github_project} and make sure it's in PATH." . PHP_EOL; 185 | } 186 | 187 | function is_installed($cmd){ 188 | $dependency_const_name = strtoupper($cmd)."_PATH"; 189 | if(shell_exec("which {$cmd}") === NULL){ 190 | if(is_executable(__DIR__."/bin/$cmd")){ 191 | define($dependency_const_name, __DIR__."/bin/$cmd"); 192 | return true; 193 | } 194 | return false; 195 | } else { 196 | define($dependency_const_name, $cmd); 197 | return true; 198 | } 199 | } 200 | 201 | function remotezip_file_list(string $url, string $mask = null): array 202 | { 203 | $files = array(); 204 | if(!filter_var($url, FILTER_VALIDATE_URL)) return $files; 205 | $cache_file_path = __DIR__.'/.cache/remotezip'.sha1($url); 206 | $cache_data = file_exists($cache_file_path) ? file_get_contents($cache_file_path) : null; 207 | if(!strlen($cache_data)) 208 | { 209 | // verbinfo("") 210 | $stdout = execute("/usr/local/bin/remotezip -l $url"); 211 | if(strlen($stdout)) 212 | { 213 | file_put_contents($cache_file_path, $stdout); 214 | } 215 | } 216 | else 217 | { 218 | $stdout = $cache_data; 219 | } 220 | // var_dump($stdout); 221 | $regex = "/(?\d+?)\s+?(?(?:.+?)\s+?(?:.+?))\s+?(?.+)(?:$|\n)/i"; 222 | if(preg_match_all($regex, $stdout, $matches)) 223 | { 224 | foreach($matches['path'] as $index => $path) 225 | { 226 | if($mask && (stristr($path, $mask) === false)) continue; 227 | $file = array( 228 | 'path' => trim($path), 229 | 'size' => (int)$matches['size'][$index], 230 | 'date' => trim($matches['date'][$index]) 231 | ); 232 | $files []= $file; 233 | } 234 | } 235 | return $files; 236 | } 237 | 238 | function remotezip_get_files(string $url, string $boardconfig):bool 239 | { 240 | execute("remotezip $url BuildManifest.plist"); 241 | $bom = bom_from_buildmanifest('BuildManifest.plist', $boardconfig); 242 | if(!$bom) return false; 243 | // create BoM and download files 244 | 245 | foreach($bom as $image_name => $image_path) 246 | { 247 | execute("remotezip $url $image_path"); 248 | if(!file_exists($image_path)) 249 | { 250 | unlink('BuildManifest.plist'); 251 | return false; 252 | } 253 | } 254 | return true; 255 | } 256 | 257 | function remotezip_get_files_old(string $url):bool 258 | { 259 | // create BoM and download files 260 | $files = remotezip_file_list($url); 261 | $dmg_files = array(); 262 | $files_needed = array( 263 | 'iBSS' => array( 264 | 'regex' => "/.*iBSS.*\.im4p$/i", 265 | 'found' => false, 266 | 'file' => null 267 | ), 268 | 'iBEC' => array( 269 | 'regex' => "/.*iBEC.*\.im4p$/i", 270 | 'found' => false, 271 | 'file' => null 272 | ), 273 | 'kernelcache' => array( 274 | 'regex' => "/^kernelcache.*/i", 275 | 'found' => false, 276 | 'file' => null 277 | ), 278 | 'devicetree' => array( 279 | 'regex' => sprintf("/.*DeviceTree\.%s\.im4p$/i", BOARDCONFIG), 280 | 'found' => false, 281 | 'file' => null 282 | ) 283 | // 'BuildManifest' => array( 284 | // 'regex' => "/^BuildManifest\.plist$/i", 285 | // 'found' => false, 286 | // 'file' => null 287 | // ), 288 | ); 289 | 290 | 291 | foreach($files as $file) 292 | { 293 | $file_path = $file['path']; 294 | 295 | if(preg_match("/.*\.dmg.*/i", $file_path)) 296 | { 297 | $dmg_files[$file['size']] = array( 298 | 'regex' => null, 299 | 'found' => true, 300 | 'file' => $file 301 | ); 302 | continue; 303 | } 304 | 305 | foreach($files_needed as $component => &$file_needed) 306 | { 307 | if($file_needed['found']) continue; 308 | if(preg_match($file_needed['regex'], $file_path)) 309 | { 310 | $file_needed['file'] = $file; 311 | $file_needed['found'] = true; 312 | } 313 | } 314 | } 315 | 316 | $sizes = array_keys($dmg_files); 317 | rsort($sizes); 318 | unset($dmg_files[current($sizes)]); 319 | $files_needed = array_merge($files_needed, $dmg_files); 320 | 321 | // download files 322 | // bad bad php (or I could pick another variable.) $file_needed simply is a reference 323 | // modifying this reference will modify the item in $files_needed array as well 324 | // so free the reference 325 | unset($file_needed); 326 | foreach($files_needed as $file_needed) 327 | { 328 | $file = $file_needed['file']; 329 | if(!$file_needed['found']) 330 | { 331 | return false; 332 | } 333 | execute("remotezip $url {$file['path']}"); 334 | if(!file_exists($file['path'])) return false; 335 | } 336 | execute("remotezip $url BuildManifest.plist"); 337 | return true; 338 | } 339 | 340 | function add_dependency_ldid2(): bool 341 | { 342 | $base_url = 'https://api.github.com'; 343 | $user_name = 'xerub'; 344 | $repo_name = 'ldid'; 345 | $url = "$base_url/repos/$user_name/$repo_name/releases"; 346 | // $url = "$base_url/repos/pwn20wndstuff/Undecimus/releases"; 347 | $working_path = __DIR__."/dependencies/$repo_name"; 348 | 349 | $data = curlget($url, ['User-Agent: make_telnet_rd']); 350 | $releases = json_decode($data); 351 | if(empty($releases)) return false; 352 | // var_dump($releases);die(); 353 | 354 | $latest_release = null; 355 | $iter_cmp_timetamp = 0; 356 | foreach($releases as $release) 357 | { 358 | $release_published_timestamp = strtotime($release->published_at); 359 | if($release_published_timestamp > $iter_cmp_timetamp) 360 | { 361 | $latest_release = $release; 362 | $iter_cmp_timetamp = $release_published_timestamp; 363 | } 364 | } 365 | Log::writeVerboseInfo("Selected {$latest_release->tag_name} of $repo_name"); 366 | if(empty($latest_release->assets)) 367 | { 368 | return false; 369 | } 370 | 371 | if(!is_dir($working_path)) 372 | { 373 | execute("mkdir -p $working_path"); 374 | } 375 | 376 | foreach($latest_release->assets as $asset) 377 | { 378 | $dl_url = $asset->browser_download_url; 379 | $dl_url_pathinfo = pathinfo($dl_url); 380 | $dl_file_path = "$working_path/{$dl_url_pathinfo['basename']}"; 381 | if($dl_url_pathinfo['extension'] === 'zip') 382 | { 383 | execute("wget $dl_url -O $dl_file_path"); 384 | if(!file_exists($dl_file_path)) 385 | { 386 | continue; 387 | } 388 | $z = new ZipArchive(); 389 | $z_open_success = $z -> open($dl_file_path); 390 | if($z_open_success === true) 391 | { 392 | if($z->locateName('ldid2') === false) 393 | { 394 | continue; 395 | } 396 | $z_extract_success = $z -> extractTo($working_path, array('ldid2')); 397 | if(!$z_extract_success) 398 | { 399 | continue; 400 | } 401 | $binary_path = "$working_path/ldid2"; 402 | if(!is_executable($binary_path)) 403 | { 404 | chmod($binary_path, 0755); 405 | if(!is_dir(__DIR__."/bin")) 406 | { 407 | mkdir(__DIR__."/bin"); 408 | } 409 | if(rename($binary_path, __DIR__."/bin/ldid2")) 410 | { 411 | return true; 412 | } 413 | } 414 | } 415 | } 416 | } 417 | 418 | return false; 419 | } 420 | 421 | function bom_from_buildmanifest(string $buildmanifest, string $boardconfig, bool $update_buildidentity = false): ?array 422 | { 423 | $restore_behavior = $update_buildidentity ? "Update" : "Erase"; 424 | Log::writeInfo("Finding buildidentity from BuildManifest.plist"); 425 | try 426 | { 427 | $bm_plist = new CFPropertyList\CFPropertyList($buildmanifest); 428 | $bm = $bm_plist->toArray(); 429 | } 430 | catch (\Exception $e) 431 | { 432 | Log::writeError("Cant parse BuildManifest.plist: " . $e->getMessage()); 433 | return null; 434 | } 435 | unset($bm_plist); // it's a quite big object 436 | $buildidentity = null; 437 | foreach($bm['BuildIdentities'] as $index => $iter_buildidentity) 438 | { 439 | // if( 440 | // ($iter_buildidentity['Info']['RestoreBehavior'] === 'Erase') && 441 | // (hexdec($iter_buildidentity['ApChipID']) === $cpid) && 442 | // (hexdec($iter_buildidentity['ApBoardID']) === $bdid ) 443 | // ) 444 | if( ($iter_buildidentity['Info']['RestoreBehavior'] === $restore_behavior) && 445 | !(strcasecmp($iter_buildidentity['Info']['DeviceClass'], $boardconfig)) ) 446 | { 447 | $buildidentity = $iter_buildidentity; 448 | Log::writeInfo("Selected {$buildidentity['ApChipID']} {$buildidentity['ApBoardID']} {$buildidentity['Info']['DeviceClass']}"); 449 | unset($bm); 450 | break; 451 | } 452 | } 453 | if(!$buildidentity) return null; 454 | $bom = array( 455 | 'RestoreDeviceTree' => null, 456 | 'RestoreKernelCache' => null, 457 | 'RestoreRamDisk' => null, 458 | 'RestoreTrustCache' => null, 459 | 'iBEC' => null, 460 | 'iBSS' => null, 461 | ); 462 | 463 | foreach($bom as $img => $_) 464 | { 465 | if(empty($buildidentity['Manifest'][$img]['Info']['Path'])) 466 | { 467 | return null; 468 | } 469 | $bom[$img] = $buildidentity['Manifest'][$img]['Info']['Path']; 470 | Log::writeInfo("Found $img -> {$bom[$img]}"); 471 | } 472 | return $bom; 473 | } 474 | 475 | function getSHSH2(string $ecid, string $device = null, string $boardconfig = null, string $version = null): ?string 476 | { 477 | $base_url = "https://api.arx8x.net/shsh3/list.php?ecid=$ecid"; 478 | $selected_files = array(); 479 | $data = curlget($base_url); 480 | if(!is_object($data)) 481 | { 482 | Log::writeError('shsh.host sent unreadable response'); 483 | return null; 484 | } 485 | // 0 is success 486 | if($data->code) 487 | { 488 | Log::writeError("{$data->code}: {$data->message}"); 489 | return null; 490 | } 491 | 492 | $shsh_files = $data->files; 493 | foreach($shsh_files as $shsh_file) 494 | { 495 | if($device && strcasecmp($shsh_file->device, $device)) continue; 496 | if($boardconfig && strcasecmp($shsh_file->boardconfig, $boardconfig)) continue; 497 | if($version && strcasecmp($shsh_file->version, $version)) continue; 498 | if(($shsh_file->extension === 'shsh2') && $shsh_file->validity) 499 | { 500 | // store all valid files to an array 501 | $selected_files []= $shsh_file; 502 | } 503 | } 504 | if(!count($selected_files)) return null; 505 | // select a random file from valid files 506 | // in case an shsh2 file doesn't work, this will likely get another file upon retrying 507 | // TODO improve this logic by saving state OR checking downloaded files and skipping over them 508 | // $selected_file = $selected_files[array_rand($selected_files)]; 509 | $selected_file = end($selected_files); 510 | 511 | if(!filter_var($selected_file->url, FILTER_VALIDATE_URL)) 512 | { 513 | Log::writeError("The file url is invalid. Re-run the script"); 514 | return null; 515 | } 516 | $file_name = basename($selected_file->url); 517 | execute("wget --trust-server-names {$selected_file->url} -O $file_name"); 518 | if(!is_file($file_name)) 519 | { 520 | Log::writeError("Couldn't download shsh2 file"); 521 | return null; 522 | } 523 | return $file_name; 524 | } 525 | 526 | function writelog(string $log_entry, int $log_type = 0, $write_stdout = true) 527 | { 528 | $log_level = defined('LOG_LEVEL') ? LOG_LEVEL : 1; 529 | $sym = '+'; 530 | } 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | ?> 541 | -------------------------------------------------------------------------------- /log.php: -------------------------------------------------------------------------------- 1 | logLevel = $log_level; 26 | $this->syms = array( 27 | LOGTYPE_ERROR => '#', 28 | LOGTYPE_WARNING => '!', 29 | LOGTYPE_INFO => '+', 30 | LOGTYPE_DEBUG => '*', 31 | LOGTYPE_INPUT => '<', 32 | LOGTYPE_OUTPUT => '>' 33 | ); 34 | if($log_file) 35 | { 36 | $this->logFile = fopen($log_file, 'w'); 37 | if(!$this->logFile) 38 | { 39 | throw new \Exception("Couldn't open the specified log file: $log_file"); 40 | return null; 41 | } 42 | } 43 | $this->stdout = fopen('php://stdout', 'w'); 44 | if(!$this->stdout) 45 | { 46 | throw new \Exception("Couldn't open stdout"); 47 | return null; 48 | } 49 | } 50 | 51 | public function terminate() 52 | { 53 | if($this->stdout) fclose($this->stdout); 54 | if($this->logFile) fclose($this->logFile); 55 | Log::$sharedInstance = null; 56 | } 57 | 58 | public static function main() 59 | { 60 | if(self::$sharedInstance == null) 61 | { 62 | self::$sharedInstance = new Log(1, 'log_telnet'); 63 | } 64 | return self::$sharedInstance; 65 | } 66 | 67 | public function writeLog(string $line, int $log_type = 1, bool $write_stdout = true) 68 | { 69 | if(!strlen($line)) return; 70 | if(empty($this->syms[$log_type])) 71 | { 72 | $log_type = LOGTYPE_INFO; 73 | } 74 | $sym = $this->syms[$log_type]; 75 | $line = (($line[0] === "\n") ? "\n" : '') . "[$sym] " . ltrim($line) . PHP_EOL; 76 | if($write_stdout) 77 | { 78 | fwrite($this->stdout, $line); 79 | } 80 | if($this->logFile) 81 | { 82 | fwrite($this->logFile, time() . ": " . $line); 83 | } 84 | } 85 | 86 | public static function writeInfo(string $line) 87 | { 88 | $log = self::main(); 89 | $log->writeLog($line, 1); 90 | } 91 | 92 | public static function writeVerboseInfo(string $line) 93 | { 94 | $log = self::main(); 95 | $log->writeLog($line, 0); 96 | } 97 | 98 | public static function writeWarning(string $line) 99 | { 100 | $log = self::main(); 101 | $log->writeLog($line, 2); 102 | } 103 | 104 | public static function writeError(string $line) 105 | { 106 | $log = self::main(); 107 | $log->writeLog($line, 3); 108 | } 109 | } 110 | 111 | 112 | 113 | 114 | 115 | ?> 116 | -------------------------------------------------------------------------------- /make_telnet_rd.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | . 20 | **************************************/ 21 | require('log.php'); 22 | require('devices.php'); 23 | require('functions.php'); 24 | require('CFPropertyList/src/CFPropertyList/CFPropertyList.php'); 25 | 26 | $instance = sha1(time()); 27 | Log::main()->writeLog("telnet_rd instance: $instance - " . date('c'), 0, false); 28 | 29 | $options = array( 30 | 'd' => array( 31 | 'longopt' => 'device', 32 | 'human_text' => 'device identifier', 33 | 'help' => 'Device identifier (example: iPhone10,4)' 34 | ), 35 | 'b' => array( 36 | 'longopt' => 'boardconfig', 37 | 'human_text' => 'BoardConfig', 38 | 'help' => 'Boardconfig (example: d201ap)' 39 | ), 40 | 'v' => array( 41 | 'longopt' => 'version', 42 | 'human_text' => 'iOS version', 43 | 'help' => 'iOS version to use as base for ramdisk' 44 | ), 45 | 's' => array( 46 | 'longopt' => 'shsh2', 47 | 'human_text' => 'shsh2 file', 48 | 'help' => 'shsh2 file (can be any version)' 49 | ), 50 | 'h' => array( 51 | 'longopt' => 'help', 52 | 'human_text' => null, 53 | 'help' => 'print this help text' 54 | ), 55 | ); 56 | 57 | 58 | $shortopts = implode(':', array_keys($options)); 59 | $args = getopt($shortopts); 60 | 61 | if(isset($args['h'])) 62 | { 63 | print_usage(); 64 | exit(0); 65 | } 66 | 67 | if(empty($args['d']) || empty($args['b'])) 68 | { 69 | Log::writeInfo("Detecting DFU device"); 70 | $detected_device = read_device(); 71 | if($detected_device) 72 | { 73 | define('DEVICE', $detected_device->identifier); 74 | define('BOARDCONFIG', $detected_device->BoardConfig); 75 | define('ECID', $detected_device->ecid); 76 | if(empty($args['s'])) 77 | { 78 | // try to get an shsh2 files using shsh.host API 79 | // TODO make getSHSH2 function get a ticket for any ECID but 80 | // with matching BNCH length. 81 | // OR 82 | // bundle two shsh2 in this project, eliminating the need to get an shsh2 file 83 | $local_shsh_files = glob("{$detected_device->ecid_raw}*{$detected_device->BoardConfig}*.shsh2"); 84 | if(empty($local_shsh_files)) 85 | { 86 | Log::writeInfo("Trying to find a usable shsh2 file on shsh.host"); 87 | $shsh_file = getSHSH2(ECID, null, BOARDCONFIG); 88 | if($shsh_file && file_exists($shsh_file)) 89 | { 90 | define('SHSH2', $shsh_file); 91 | } 92 | } 93 | else 94 | { 95 | define('SHSH2', $local_shsh_files[array_rand($local_shsh_files)]); 96 | Log::writeInfo("Choosing shsh2 from local files: ". SHSH2); 97 | } 98 | } 99 | } 100 | } 101 | 102 | if(empty($args['v'])) 103 | { 104 | // automatically choose versions based on success rate 105 | // A11 - 13.5, 13.7, 14,2 106 | // I don't have enough data on this 107 | } 108 | 109 | 110 | foreach($options as $opt_short => $opt) 111 | { 112 | if(!$opt['human_text']) continue; 113 | $constant_name = strtoupper($opt['longopt']); 114 | if(defined($constant_name)) continue; 115 | if(empty($args[$opt_short])) 116 | { 117 | Log::writeError("[ERROR] {$opt['human_text']} not specified (use -$opt_short)\n\n"); 118 | print_usage(); 119 | exit(-1); 120 | } 121 | define(strtoupper($opt['longopt']), $args[$opt_short]); 122 | } 123 | 124 | define("WD","WD_" . DEVICE . "-" . BOARDCONFIG . "-" . VERSION . "_telnet_rd"); 125 | Log::writeVerboseInfo("Working directory set as " . WD); 126 | 127 | if(!file_exists(SHSH2)) 128 | { 129 | Log::writeError(".shsh2 file doesn't exist or isn't readable" . PHP_EOL); 130 | exit(-1); 131 | } 132 | define("SHSH2_ABS",realpath(SHSH2)); // I shouldn't have started using constants lol (I agree - ARX8x) 133 | 134 | Log::writeInfo("Checking for dependencies"); 135 | if(!is_installed("diskutil") || !is_installed("hdiutil") || !is_installed("unzip") || !is_installed("plutil") || !is_installed("curl")){ 136 | Log::writeError("Couldn't find diskutil, unzip, plutil, curl or hdiutil. Please use a mac." . PHP_EOL); 137 | exit(-1); 138 | } 139 | $dependencies = array( 140 | "img4" => "https://github.com/xerub/img4lib", 141 | "img4tool" => "https://github.com/tihmstar/img4tool", 142 | "ldid2"=>"https://github.com/xerub/ldid/releases/", 143 | "autodecrypt" => "https://github.com/matteyeux/autodecrypt", 144 | "kairos" => "https://github.com/dayt0n/kairos", 145 | "iproxy" => "https://github.com/libimobiledevice/libusbmuxd", 146 | "Kernel64Patcher" => "https://github.com/Ralph0045/Kernel64Patcher", 147 | "irecovery" => "https://github.com/libimobiledevice/libirecovery", 148 | "remotezip" => "https://pypi.org/project/remotezip/" 149 | ); 150 | 151 | foreach($dependencies as $dependency_cmd => $dependency_source) 152 | { 153 | Log::writeInfo("Checking dependency: $dependency_cmd"); 154 | $dependency_available = is_installed($dependency_cmd); 155 | if($dependency_cmd === 'remotezip') 156 | { 157 | define("HAS_REMOTEZIP", $dependency_available); 158 | if(!HAS_REMOTEZIP) 159 | { 160 | Log::writeInfo("remotezip is a python library that allows you to download files from ipsw without downloading the entire ipsw. It's not necessary but it'll save time and resources\n"); 161 | // since it's an optional dependency, skip over it even if it doesn't exist 162 | continue; 163 | } 164 | } 165 | 166 | if(!$dependency_available) 167 | { 168 | // attempt to automatically build the dependency 169 | $dependency_function = "add_dependency_$dependency_cmd"; 170 | if(is_callable($dependency_function)) 171 | { 172 | Log::writeInfo("Attempting to install $dependency_cmd"); 173 | $dependency_function(); 174 | if(is_installed($dependency_cmd)) continue; 175 | } 176 | Log::writeError(pls_install_msg($dependency_source)); 177 | if($dependency_cmd === 'irecovery') 178 | { 179 | Log::writeInfo("You can also install it with brew install libimobiledevice or something if you're lazy"); 180 | } 181 | die(); 182 | } 183 | } 184 | 185 | define("HAS_WGET",is_installed("wget")); 186 | Log::writeInfo("Dependency check completed\n"); 187 | 188 | // info("Creating & entering working directory if it doesn't exist: " . WD); 189 | if(!is_dir(WD)) {mkdir(WD);} 190 | chdir(WD); 191 | 192 | if(!file_exists("BuildManifest.plist")) 193 | { 194 | $url = get_ipsw_url(DEVICE, VERSION); 195 | if(!$url) exit(-1); 196 | $got_files = false; 197 | if(HAS_REMOTEZIP) 198 | { 199 | Log::writeInfo("Attempting to get files with remotezip"); 200 | if(($got_files = remotezip_get_files($url, BOARDCONFIG))) 201 | { 202 | Log::writeInfo("remotezip seems to have downloaded all files"); 203 | } 204 | } 205 | if(!$got_files) 206 | { 207 | define("FWFILE",DEVICE . "_" . VERSION . ".ipsw"); 208 | Log::writeInfo("Downloading ipsw (it will continue/just finish if it's already (partially) there)"); 209 | if(HAS_WGET){ 210 | execute("wget -q --show-progress --progress=bar:force \"" . addslashes($url) . "\" -cO " . FWFILE . ""); 211 | } else { 212 | execute("curl \"" . addslashes($url) . "\" -o " . FWFILE . " -C -"); 213 | } 214 | Log::writeInfo("Extracting ipsw"); 215 | execute("unzip " . FWFILE,1); 216 | } 217 | } else { 218 | Log::writeInfo("BuildManifest.plist already exists, not attempting to resume ipsw download and extraction"); 219 | } 220 | 221 | // TODO use bom to determine files to extract and use 222 | Log::writeInfo("Finding ramdisk and trustcache name by trying to convert and mount them"); 223 | $ramdiskexisted = false; 224 | if(file_exists("ramdisk.dmg")){ 225 | $ramdiskexisted = true; 226 | Log::writeVerboseInfo("ramdisk.dmg already exists, renaming it as we still need to know its original name"); 227 | if(file_exists("ramdisk.dmg.orig")){die("ramdisk.dmg.orig exists, please only run one instance of this program at once or delete ramdisk.dmg.orig" . PHP_EOL);} 228 | rename("ramdisk.dmg","ramdisk.dmg.orig"); 229 | if(!file_exists("ramdisk.dmg.orig")){die("rename failed" . PHP_EOL);} 230 | } 231 | $dmgs = Array(); 232 | $sizes = Array(); 233 | foreach(glob("*.dmg") as $dmg){ 234 | $dmgs[$sizes[] = filesize($dmg)] = $dmg; 235 | } 236 | sort($sizes); 237 | for($i = 0; $i&1",1); 241 | if($try === "rdsk\n"){ 242 | $mount_point = mount_rd(); 243 | Log::writeVerboseInfo("Mounted potential ramdisk at \"{$mount_point}\""); 244 | Log::writeVerboseInfo("Unmounting again because we don't need it right now"); 245 | unmount($mount_point); 246 | if(strpos($mount_point,"CustomerRamDisk") !== false){ 247 | Log::writeInfo("Found ramdisk to be {$maybe}"); 248 | define("RAMDISK",$maybe); 249 | break; 250 | } else { 251 | Log::writeVerboseInfo("{$maybe} can't be it, because it mounts wrong"); 252 | @unlink("ramdisk.dmg"); 253 | } 254 | } else { 255 | Log::writeVerboseInfo("{$maybe} can't be it, because img4 doesn't want to convert it"); 256 | @unlink("ramdisk.dmg"); 257 | } 258 | } 259 | if($ramdiskexisted){ 260 | unlink("ramdisk.dmg"); 261 | rename("ramdisk.dmg.orig","ramdisk.dmg"); 262 | } 263 | 264 | if(!defined("RAMDISK")) 265 | { 266 | Log::writeError("Couldn't find ramdisk\n"); 267 | exit(-1); 268 | } 269 | 270 | 271 | 272 | Log::writeInfo("\nBeginning to patch and sign things"); 273 | 274 | //kernelcache 275 | if(!file_exists("kcache.raw")){ 276 | Log::writeInfo("converting kernelcache"); 277 | execute("img4 -i kernelcache.* -o kcache.raw"); 278 | } else { 279 | Log::writeVerboseInfo("kcache.raw already exists, not converting kernelcache"); 280 | } 281 | if(!file_exists("kcache.patched")){ 282 | Log::writeInfo("patching signature checks on kernelcache"); 283 | execute("Kernel64Patcher kcache.raw kcache.patched -a"); 284 | } else { 285 | Log::writeVerboseInfo("kcache.patched already exists, skipping step"); 286 | } 287 | if(!file_exists("IM4M")){ 288 | Log::writeInfo("Converting shshs2 to IM4M"); 289 | execute("img4tool -e -s " . SHSH2_ABS . " -m IM4M"); 290 | } else { 291 | Log::writeVerboseInfo("IM4M already exists, skipping conversion of .shsh2 into it"); 292 | } 293 | if(!file_exists("kernelcache.im4p")){ 294 | Log::writeInfo("Compressing kernelcache back"); 295 | execute("img4tool -c kernelcache.im4p -t rkrn kcache.patched --compression complzss"); 296 | } else { 297 | Log::writeVerboseInfo("kernelcache.im4p already exists, not compressing kernel again"); 298 | } 299 | if(!file_exists("kernelcache.img4")){ 300 | Log::writeInfo("Stitching IM4M to kernelcache"); 301 | execute("img4tool -c kernelcache.img4 -p kernelcache.im4p -m IM4M"); 302 | } else { 303 | Log::writeVerboseInfo("kernelcache.img4 already exists, skipping packing into .img4"); 304 | } 305 | $ibss = glob("iBSS.*.RELEASE.bin"); 306 | if(sizeof($ibss) == 0){ 307 | Log::writeInfo("Decrypting iBSS"); 308 | execute("bash -c 'mkdir tmpdir && pushd tmpdir && autodecrypt -f iBSS -i " . VERSION . " -d " . DEVICE . " && mv -v * .. && popd && rmdir tmpdir'"); 309 | } else { 310 | Log::writeVerboseInfo("Some file matching the pattern iBSS.*.RELEASE.bin already exists, skipping iBSS downloading and decrypting"); 311 | } 312 | if(!file_exists("iBSS.patched")){ 313 | Log::writeInfo("Patching iBSS"); 314 | execute("kairos iBSS.*.RELEASE.bin iBSS.patched"); 315 | } else { 316 | Log::writeVerboseInfo("iBSS.patched already exists, not patching"); 317 | } 318 | $ibec = glob("iBEC.*.RELEASE.bin"); 319 | if(sizeof($ibec) == 0){ 320 | Log::writeInfo("Decrypting iBEC"); 321 | execute("bash -c 'mkdir tmpdir && pushd tmpdir && autodecrypt -f iBEC -i " . VERSION . " -d " . DEVICE . " && mv -v * .. && popd && rmdir tmpdir'"); 322 | } else { 323 | Log::writeVerboseInfo("Some file matching the pattern iBEC.*.RELEASE.im4p already exists, skipping iBEC downloading and decrypting"); 324 | } 325 | if(!file_exists("iBEC.patched")){ 326 | Log::writeInfo("Patching iBEC"); 327 | execute("kairos iBEC.*.RELEASE.bin iBEC.patched -b \"rd=md0 -v\""); 328 | } else { 329 | Log::writeVerboseInfo("iBEC.patched already exists, not patching"); 330 | } 331 | if(!file_exists("iBSS.img4")){ 332 | execute("img4 -i iBSS.patched -o iBSS.img4 -M IM4M -A -T ibss"); 333 | Log::writeInfo("Stitching IM4M to iBSS"); 334 | } else { 335 | Log::writeVerboseInfo("iBSS.patched already exists, not signing patched iBSS"); 336 | } 337 | if(!file_exists("iBEC.img4")){ 338 | Log::writeInfo("Stitching IM4M to iBEC"); 339 | execute("img4 -i iBEC.patched -o iBEC.img4 -M IM4M -A -T ibec"); 340 | } else { 341 | Log::writeVerboseInfo("iBEC.patched already exists, not signing patched iBEC"); 342 | } 343 | if(!file_exists("trustcache.img4")){ 344 | Log::writeInfo("Stitching IM4M to trustcache"); 345 | execute("img4 -i Firmware/" . RAMDISK .".trustcache -o trustcache.img4 -M IM4M"); 346 | } else { 347 | Log::writeVerboseInfo("trustcache.img4 already exists, not signing"); 348 | } 349 | if(!file_exists("devicetree.img4")){ 350 | $orig_devicetree = "Firmware/all_flash/DeviceTree." . strtolower(BOARDCONFIG) . ".im4p"; 351 | if(!file_exists($orig_devicetree)){ 352 | Log::writeInfo("Couldn't find devicetree at {$orig_devicetree}, selecting closest other one"); 353 | foreach(glob("Firmware/all_flash/DeviceTree.*.im4p") as $devicetree){ 354 | $potential_devicetrees[$devicetree] = levenshtein($devicetree,BOARDCONFIG); 355 | } 356 | $orig_devicetree = array_search(min($potential_devicetrees),$potential_devicetrees); 357 | Log::writeInfo("Selected {$orig_devicetree} instead"); 358 | } 359 | execute("img4 -i {$orig_devicetree} -o devicetree.img4 -M IM4M -T rdtr"); 360 | } else { 361 | Log::writeVerboseInfo("devicetree.img4 already exists, skipping singing"); 362 | } 363 | 364 | 365 | Log::writeInfo("\nWe now have everything needed to boot the ramdisk, just need to customize the ramdisk!"); 366 | 367 | if(ask("I'm about to add utilities and modify the ramdisk.\nHave you made manual changes to ramdisk.dmg and only want me to sign it? Enter y.\nFor default just press enter ")) { 368 | Log::writeInfo("Not adding utilities, just signing"); 369 | } 370 | else { 371 | Log::writeVerboseInfo("enlarging ramdisk"); 372 | execute("hdiutil resize -size 150MB ramdisk.dmg"); 373 | $mountpoint = mount_rd(); 374 | Log::writeInfo("Mounted RAMdisk at {$mountpoint} and now adding tools"); 375 | execute("xcrun -sdk iphoneos clang -arch arm64 " . dirname(__FILE__) . "/resources/restored_external.c -o restored_external"); 376 | execute(LDID2_PATH." -S restored_external"); 377 | Log::writeVerboseInfo("compiled restored_external"); 378 | if(!file_exists("{$mountpoint}/usr/local/bin/restored_external_original")){ 379 | Log::writeVerboseInfo("renaming old one"); 380 | execute("mv -v \"{$mountpoint}/usr/local/bin/restored_external\" \"{$mountpoint}/usr/local/bin/restored_external_original\"",1); 381 | } 382 | Log::writeVerboseInfo("adding new one"); 383 | execute("cp -v restored_external \"{$mountpoint}/usr/local/bin/restored_external\""); 384 | Log::writeVerboseInfo("Downloading executables"); 385 | $package_dir = __DIR__."/debs/"; 386 | if(!is_dir($package_dir)){mkdir($package_dir);} 387 | chdir($package_dir); 388 | // apt download --print-uris inetutils ncurses ncurses5-libs readline coreutils-bin firmware-sbin system-cmds nano bash sed grep htop findutils less coreutils profile.d com.bingner.snappy 389 | $apt_download_output = "'https://apt.bingner.com/debs/1443.00/bash_5.0.3-2_iphoneos-arm.deb' bash_5.0.3-2_iphoneos-arm.deb 480482 SHA256:078a0a6dc0619dc5db2cbb411a925ab5c08810279994714fd0343fc63f7d4072 390 | 'https://apt.bingner.com/debs/1443.00/com.bingner.snappy_1.3.0_iphoneos-arm.deb' com.bingner.snappy_1.3.0_iphoneos-arm.deb 15438 SHA256:7e9db38dd7959de4484ee686c4cf8e31c47362c43865ae2e0466af190a49d484 391 | 'https://apt.bingner.com/debs/1443.00/coreutils_8.31-1_iphoneos-arm.deb' coreutils_8.31-1_iphoneos-arm.deb 714854 SHA256:37a125683866d6afa27979f39ccad3d1e2b187c33f09a9cc291c9e9b1f14a006 392 | 'https://apt.bingner.com/debs/1443.00/coreutils-bin_8.31-1_iphoneos-arm.deb' coreutils-bin_8.31-1_iphoneos-arm.deb 679670 SHA256:b4625d37d45684317766ec4c101dc37d6a750851defeb0a175c9d9f3be7f9728 393 | 'https://apt.bingner.com/debs/1443.00/findutils_4.6.0-2_iphoneos-arm.deb' findutils_4.6.0-2_iphoneos-arm.deb 212748 SHA256:fb683abb9c0c7ca3b6bcb3aa87ce31785ad2480fd46e650c2fc757a22fa51516 394 | 'https://apt.bingner.com/debs/1443.00/firmware-sbin_0-1_iphoneos-all.deb' firmware-sbin_0-1_all.deb 2050 SHA256:ab782faee7925d2702467b7a837ea8755445589de2a3eb8e6b8bd52e6e2d2440 395 | 'https://apt.bingner.com/debs/1443.00/grep_3.1-1_iphoneos-arm.deb' grep_3.1-1_iphoneos-arm.deb 91310 SHA256:b2b9473623f867735d878ee12b76af26084bbcf7bf5788a8985a579d8b806bbe 396 | 'https://apt.bingner.com/debs/1443.00/htop_2.2.0-1_iphoneos-arm.deb' htop_2.2.0-1_iphoneos-arm.deb 47260 SHA256:56c85b1f968912ab7c85b2561923c0231b1493b6899842552a7da1889d0520f3 397 | 'https://apt.bingner.com/debs/1443.00/inetutils_1.9.4-2_iphoneos-arm.deb' inetutils_1.9.4-2_iphoneos-arm.deb 268236 SHA256:4fc0c494701bdb6fa4538788c77d63024960308cc657b72a9e8cc9c09bf9019d 398 | 'https://apt.bingner.com/debs/1443.00/less_530-2_iphoneos-arm.deb' less_530-2_iphoneos-arm.deb 73896 SHA256:71b2db9247ca5342c635d5f95bc43f56d09af2d42a6f5602144f6ec37ee6a5a0 399 | 'https://apt.bingner.com/debs/1443.00/nano_4.5-1_iphoneos-arm.deb' nano_4.5-1_iphoneos-arm.deb 174454 SHA256:a174f328475b3c926c4074880cc1535873ed5ebb1b303c4aeeba38d4108306a9 400 | 'https://apt.bingner.com/debs/1443.00/ncurses_6.1+20181013-1_iphoneos-arm.deb' ncurses_6.1+20181013-1_iphoneos-arm.deb 365394 SHA256:e55c55c9d61f3a3b0c1fd1a3df1add4083a6d3e891f87fb698c57d33d2365567 401 | 'https://apt.bingner.com/debs/1443.00/ncurses5-libs_5.9-1_iphoneos-arm.deb' ncurses5-libs_5.9-1_iphoneos-arm.deb 174740 SHA256:3001282a457fc30ea5e79b9a13fcd2f972640e2d78880d5099c4f5e2de484225 402 | 'https://apt.bingner.com/debs/1443.00/profile.d_0-1_iphoneos-arm.deb' profile.d_0-1_iphoneos-arm.deb 918 SHA256:c83306dc925b5a7844098a496b8fd3eb1c3787dea912b6f7c4611d64fc651194 403 | 'https://apt.bingner.com/debs/1443.00/readline_8.0-1_iphoneos-arm.deb' readline_8.0-1_iphoneos-arm.deb 129432 SHA256:60b71efee41f78b7c427fc575c544a6ea573e4bf07520099a579e2855a040ae4 404 | 'https://apt.bingner.com/debs/1443.00/sed_4.5-1_iphoneos-arm.deb' sed_4.5-1_iphoneos-arm.deb 76688 SHA256:8a8e92b8e611514f163ca56e6fd05cbcd9f457f07d4d87ccc9202a1c6b157422 405 | 'https://apt.bingner.com/debs/1443.00/system-cmds_790.30.1-2_iphoneos-arm.deb' system-cmds_790.30.1-2_iphoneos-arm.deb 94086 SHA256:5d657d85f7e57452b76037b78e1bd0ae64421309d7c1f43cff22a6e42d3adeaf"; 406 | foreach(explode("\n",$apt_download_output) as $line){ 407 | $url = explode("'",$line)[1]; 408 | if(HAS_WGET){ 409 | execute("wget --trust-server-names -c \"{$url}\""); 410 | } else { 411 | execute("curl -C - -O \"{$url}\""); 412 | } 413 | } 414 | $debs = glob("*.deb"); 415 | Log::writeVerboseInfo("Extracting debs " . implode(", ",$debs)); 416 | if(!is_dir("staging")){ 417 | mkdir("staging"); 418 | } 419 | foreach($debs as $deb){ 420 | $debdir = $deb . ".dir"; 421 | if(!is_dir($debdir)){ 422 | mkdir($debdir); 423 | } 424 | chdir($debdir); 425 | execute("ar -vx ../{$deb}",1); 426 | execute("tar -C ../staging/ -xzvkf data.*",1); 427 | chdir(".."); 428 | } 429 | Log::writeVerboseInfo("Downloading and installing busybox (if Sam Bingner) still hosts it"); 430 | if(HAS_WGET){ 431 | execute("wget https://www.bingner.com/busybox.gz -c -O busybox.gz"); 432 | } else { 433 | execute("curl https://www.bingner.com/busybox.gz -C - -o busybox.gz"); 434 | } 435 | execute("cat busybox.gz|gzip -d > busybox"); 436 | execute("chmod +xxx busybox"); 437 | execute(LDID2_PATH." -S busybox"); 438 | execute(LDID2_PATH." -S ./staging/usr/bin/htop"); 439 | execute(LDID2_PATH." -S ./staging/usr/bin/find"); // idk if this makes them not die with Killed: 9 and why they do it otherwise 440 | execute("cp -v busybox ./staging/bin/"); 441 | Log::writeVerboseInfo("Syncing extracted debs into fs"); 442 | execute("rsync --ignore-existing -avhuK --progress ./staging/ \"{$mountpoint}/\""); // this is necessary because tar overwrites symlinks smh 443 | chdir(__DIR__ . '/' . WD); 444 | foreach(Array("/var/root","/var/run") as $extra_directory){ 445 | $dir = $mountpoint . $extra_directory; 446 | if(!is_dir($dir)){ 447 | mkdir($dir); 448 | } 449 | } 450 | foreach(glob(dirname(__FILE__) . "/resources/etc/*") as $etcfile){ 451 | $to = $mountpoint . "/etc/" . basename($etcfile); 452 | Log::writeVerboseInfo("copying {$etcfile} to {$to}"); 453 | execute("cp -v \"{$etcfile}\" \"{$to}\"",1); 454 | } 455 | // execute("img4tool -c sep-firmware.img4 -p Firmware/all_flash/sep-firmware.d211.RELEASE.im4p -m IM4M"); // this will 99% never work, leaving it here as legacy. A missing sep-firmware.img4 can't be recovered. 456 | // execute("cp -v sep-firmware.img4 {$mountpoint}/usr/standalone/firmware/"); 457 | unmount($mountpoint); 458 | } 459 | execute("img4 -i ramdisk.dmg -o ramdisk -M IM4M -A -T rdsk"); 460 | $bootrd = dirname(__FILE__) . "/bootrd_" . BOARDCONFIG . '_' . VERSION . ".sh"; 461 | Log::writeInfo("All done, writing bootscript to bootrd.sh. Execute ./bootrd_" . VERSION . ".sh to boot."); 462 | if(!file_exists("../PyBoot/pyboot.py")){ 463 | Log::writeInfo("You have not successfully cloned pyboot, doing it for you."); 464 | chdir("../PyBoot/"); 465 | if(HAS_WGET){ 466 | execute("wget -c https://github.com/MatthewPierson/PyBoot/archive/master.zip",1); 467 | } else { 468 | execute("curl -C - -o master.zip https://github.com/MatthewPierson/PyBoot/archive/master.zip",1); 469 | } 470 | execute("unzip master.zip",1); 471 | execute("mv -v PyBoot-master/* .",1); 472 | execute("rm -rvf PyBoot-master",1); 473 | unlink("master.zip"); 474 | Log::writeInfo("Try cloning with --recursive next time."); 475 | } 476 | Log::writeInfo("\nPreparing boot script: $bootrd"); 477 | file_put_contents($bootrd,"#!/usr/bin/env bash 478 | cd PyBoot 479 | ./pyboot.py -p 480 | cd ../" . WD . " 481 | sleep 1 482 | irecovery -f iBSS.img4 483 | sleep 1 484 | irecovery -f iBSS.img4 485 | sleep 1 486 | irecovery -f iBEC.img4 487 | sleep 1 488 | irecovery -c go 489 | sleep 1 490 | irecovery -f ramdisk 491 | sleep 1 492 | irecovery -c ramdisk 493 | sleep 1 494 | irecovery -f devicetree.img4 495 | sleep 1 496 | irecovery -c devicetree 497 | sleep 1 498 | irecovery -f trustcache.img4 499 | sleep 1 500 | irecovery -c firmware 501 | sleep 1 502 | irecovery -f kernelcache.img4 503 | sleep 1 504 | irecovery -c bootx 505 | echo Alright, now run 'iproxy 2323 23' to start the proxy, and in a new tab connect with 'telnet 127.0.0.1 2323' as soon as the screen turns white. Login with username: root, password: alpine. Screen will get black after like two minutes but you should still have connectivity."); 506 | execute("chmod -v +xxx {$bootrd}",1); 507 | if(ask("Cool, now pray it worked. Enter yes to boot directly (you need to be in DFU mode): ")){ 508 | chdir(dirname(__FILE__)); 509 | execute($bootrd); 510 | } 511 | 512 | Log::main()->writeLog("telnet_rd exit"); 513 | 514 | 515 | ?> 516 | -------------------------------------------------------------------------------- /resources/etc/hosts: -------------------------------------------------------------------------------- 1 | ## 2 | # Host Database 3 | # 4 | # localhost is used to configure the loopback interface 5 | # when the system is booting. Do not change this entry. 6 | ## 7 | 127.0.0.1 localhost 8 | 255.255.255.255 broadcasthost 9 | ::1 localhost 10 | -------------------------------------------------------------------------------- /resources/etc/hosts.allow: -------------------------------------------------------------------------------- 1 | in.telnetd: 127.0.0.1 2 | -------------------------------------------------------------------------------- /resources/etc/inetd.conf: -------------------------------------------------------------------------------- 1 | telnet stream tcp nowait root /usr/libexec/telnetd --exec-login=/bin/bash 2 | -------------------------------------------------------------------------------- /resources/etc/networks: -------------------------------------------------------------------------------- 1 | ## 2 | # Networks Database 3 | ## 4 | loopback 127 loopback-net 5 | -------------------------------------------------------------------------------- /resources/etc/profile: -------------------------------------------------------------------------------- 1 | export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games' 2 | export PS1='\h:\w \u\$ ' 3 | umask 022 4 | 5 | for i in /etc/profile.d/*.sh ; do 6 | if [ -r "$i" ]; then 7 | . $i 8 | fi 9 | done 10 | -------------------------------------------------------------------------------- /resources/etc/protocols: -------------------------------------------------------------------------------- 1 | # 2 | # Internet protocols 3 | # 4 | # $FreeBSD$ 5 | # from: @(#)protocols 5.1 (Berkeley) 4/17/89 6 | # 7 | # See also http://www.iana.org/assignments/protocol-numbers 8 | # 9 | ip 0 IP # internet protocol, pseudo protocol number 10 | #hopopt 0 HOPOPT # hop-by-hop options for ipv6 11 | icmp 1 ICMP # internet control message protocol 12 | igmp 2 IGMP # internet group management protocol 13 | ggp 3 GGP # gateway-gateway protocol 14 | ipencap 4 IP-ENCAP # IP encapsulated in IP (officially ``IP'') 15 | st2 5 ST2 # ST2 datagram mode (RFC 1819) (officially ``ST'') 16 | tcp 6 TCP # transmission control protocol 17 | cbt 7 CBT # CBT, Tony Ballardie 18 | egp 8 EGP # exterior gateway protocol 19 | igp 9 IGP # any private interior gateway (Cisco: for IGRP) 20 | bbn-rcc 10 BBN-RCC-MON # BBN RCC Monitoring 21 | nvp 11 NVP-II # Network Voice Protocol 22 | pup 12 PUP # PARC universal packet protocol 23 | argus 13 ARGUS # ARGUS 24 | emcon 14 EMCON # EMCON 25 | xnet 15 XNET # Cross Net Debugger 26 | chaos 16 CHAOS # Chaos 27 | udp 17 UDP # user datagram protocol 28 | mux 18 MUX # Multiplexing protocol 29 | dcn 19 DCN-MEAS # DCN Measurement Subsystems 30 | hmp 20 HMP # host monitoring protocol 31 | prm 21 PRM # packet radio measurement protocol 32 | xns-idp 22 XNS-IDP # Xerox NS IDP 33 | trunk-1 23 TRUNK-1 # Trunk-1 34 | trunk-2 24 TRUNK-2 # Trunk-2 35 | leaf-1 25 LEAF-1 # Leaf-1 36 | leaf-2 26 LEAF-2 # Leaf-2 37 | rdp 27 RDP # "reliable datagram" protocol 38 | irtp 28 IRTP # Internet Reliable Transaction Protocol 39 | iso-tp4 29 ISO-TP4 # ISO Transport Protocol Class 4 40 | netblt 30 NETBLT # Bulk Data Transfer Protocol 41 | mfe-nsp 31 MFE-NSP # MFE Network Services Protocol 42 | merit-inp 32 MERIT-INP # MERIT Internodal Protocol 43 | dccp 33 DCCP # Datagram Congestion Control Protocol 44 | 3pc 34 3PC # Third Party Connect Protocol 45 | idpr 35 IDPR # Inter-Domain Policy Routing Protocol 46 | xtp 36 XTP # Xpress Tranfer Protocol 47 | ddp 37 DDP # Datagram Delivery Protocol 48 | idpr-cmtp 38 IDPR-CMTP # IDPR Control Message Transport Proto 49 | tp++ 39 TP++ # TP++ Transport Protocol 50 | il 40 IL # IL Transport Protocol 51 | ipv6 41 IPV6 # ipv6 52 | sdrp 42 SDRP # Source Demand Routing Protocol 53 | ipv6-route 43 IPV6-ROUTE # routing header for ipv6 54 | ipv6-frag 44 IPV6-FRAG # fragment header for ipv6 55 | idrp 45 IDRP # Inter-Domain Routing Protocol 56 | rsvp 46 RSVP # Resource ReSerVation Protocol 57 | gre 47 GRE # Generic Routing Encapsulation 58 | dsr 48 DSR # Dynamic Source Routing Protocol 59 | bna 49 BNA # BNA 60 | esp 50 ESP # encapsulating security payload 61 | ah 51 AH # authentication header 62 | i-nlsp 52 I-NLSP # Integrated Net Layer Security TUBA 63 | swipe 53 SWIPE # IP with Encryption 64 | narp 54 NARP # NBMA Address Resolution Protocol 65 | mobile 55 MOBILE # IP Mobility 66 | tlsp 56 TLSP # Transport Layer Security Protocol 67 | skip 57 SKIP # SKIP 68 | ipv6-icmp 58 IPV6-ICMP icmp6 # ICMP for IPv6 69 | ipv6-nonxt 59 IPV6-NONXT # no next header for ipv6 70 | ipv6-opts 60 IPV6-OPTS # destination options for ipv6 71 | # 61 # any host internal protocol 72 | cftp 62 CFTP # CFTP 73 | # 63 # any local network 74 | sat-expak 64 SAT-EXPAK # SATNET and Backroom EXPAK 75 | kryptolan 65 KRYPTOLAN # Kryptolan 76 | rvd 66 RVD # MIT Remote Virtual Disk Protocol 77 | ippc 67 IPPC # Internet Pluribus Packet Core 78 | # 68 # any distributed filesystem 79 | sat-mon 69 SAT-MON # SATNET Monitoring 80 | visa 70 VISA # VISA Protocol 81 | ipcv 71 IPCV # Internet Packet Core Utility 82 | cpnx 72 CPNX # Computer Protocol Network Executive 83 | cphb 73 CPHB # Computer Protocol Heart Beat 84 | wsn 74 WSN # Wang Span Network 85 | pvp 75 PVP # Packet Video Protocol 86 | br-sat-mon 76 BR-SAT-MON # Backroom SATNET Monitoring 87 | sun-nd 77 SUN-ND # SUN ND PROTOCOL-Temporary 88 | wb-mon 78 WB-MON # WIDEBAND Monitoring 89 | wb-expak 79 WB-EXPAK # WIDEBAND EXPAK 90 | iso-ip 80 ISO-IP # ISO Internet Protocol 91 | vmtp 81 VMTP # Versatile Message Transport 92 | secure-vmtp 82 SECURE-VMTP # SECURE-VMTP 93 | vines 83 VINES # VINES 94 | ttp 84 TTP # TTP 95 | #iptm 84 IPTM # Protocol Internet Protocol Traffic 96 | nsfnet-igp 85 NSFNET-IGP # NSFNET-IGP 97 | dgp 86 DGP # Dissimilar Gateway Protocol 98 | tcf 87 TCF # TCF 99 | eigrp 88 EIGRP # Enhanced Interior Routing Protocol (Cisco) 100 | ospf 89 OSPFIGP # Open Shortest Path First IGP 101 | sprite-rpc 90 Sprite-RPC # Sprite RPC Protocol 102 | larp 91 LARP # Locus Address Resolution Protocol 103 | mtp 92 MTP # Multicast Transport Protocol 104 | ax.25 93 AX.25 # AX.25 Frames 105 | ipip 94 IPIP # Yet Another IP encapsulation 106 | micp 95 MICP # Mobile Internetworking Control Pro. 107 | scc-sp 96 SCC-SP # Semaphore Communications Sec. Pro. 108 | etherip 97 ETHERIP # Ethernet-within-IP Encapsulation 109 | encap 98 ENCAP # Yet Another IP encapsulation 110 | # 99 # any private encryption scheme 111 | gmtp 100 GMTP # GMTP 112 | ifmp 101 IFMP # Ipsilon Flow Management Protocol 113 | pnni 102 PNNI # PNNI over IP 114 | pim 103 PIM # Protocol Independent Multicast 115 | aris 104 ARIS # ARIS 116 | scps 105 SCPS # SCPS 117 | qnx 106 QNX # QNX 118 | a/n 107 A/N # Active Networks 119 | ipcomp 108 IPComp # IP Payload Compression Protocol 120 | snp 109 SNP # Sitara Networks Protocol 121 | compaq-peer 110 Compaq-Peer # Compaq Peer Protocol 122 | ipx-in-ip 111 IPX-in-IP # IPX in IP 123 | carp 112 CARP vrrp # Common Address Redundancy Protocol 124 | pgm 113 PGM # PGM Reliable Transport Protocol 125 | # 114 # any 0-hop protocol 126 | l2tp 115 L2TP # Layer Two Tunneling Protocol 127 | ddx 116 DDX # D-II Data Exchange 128 | iatp 117 IATP # Interactive Agent Transfer Protocol 129 | stp 118 STP # Schedule Transfer Protocol 130 | srp 119 SRP # SpectraLink Radio Protocol 131 | uti 120 UTI # UTI 132 | smp 121 SMP # Simple Message Protocol 133 | sm 122 SM # SM 134 | ptp 123 PTP # Performance Transparency Protocol 135 | isis 124 ISIS # ISIS over IPv4 136 | fire 125 FIRE 137 | crtp 126 CRTP # Combat Radio Transport Protocol 138 | crudp 127 CRUDP # Combat Radio User Datagram 139 | sscopmce 128 SSCOPMCE 140 | iplt 129 IPLT 141 | sps 130 SPS # Secure Packet Shield 142 | pipe 131 PIPE # Private IP Encapsulation within IP 143 | sctp 132 SCTP # Stream Control Transmission Protocol 144 | fc 133 FC # Fibre Channel 145 | rsvp-e2e-ignore 134 RSVP-E2E-IGNORE # Aggregation of RSVP for IP reservations 146 | mobility-header 135 Mobility-Header # Mobility Support in IPv6 147 | udplite 136 UDPLite # The UDP-Lite Protocol 148 | mpls-in-ip 137 MPLS-IN-IP # Encapsulating MPLS in IP 149 | manet 138 MANET # MANET Protocols (RFC5498) 150 | hip 139 HIP # Host Identity Protocol (RFC5201) 151 | shim6 140 SHIM6 # Shim6 Protocol (RFC5533) 152 | wesp 141 WESP # Wrapped Encapsulating Security Payload (RFC5840) 153 | rohc 142 ROHC # Robust Header Compression (RFC5858) 154 | # 138-254 # Unassigned 155 | pfsync 240 PFSYNC # PF Synchronization 156 | # 253-254 # Use for experimentation and testing (RFC3692) 157 | # 255 # Reserved 158 | divert 258 DIVERT # Divert pseudo-protocol [non IANA] 159 | -------------------------------------------------------------------------------- /resources/etc/screenrc: -------------------------------------------------------------------------------- 1 | # 2 | # This is an example for the global screenrc file. 3 | # You may want to install this file as /usr/local/etc/screenrc. 4 | # Check config.h for the exact location. 5 | # 6 | # Flaws of termcap and standard settings are done here. 7 | # 8 | 9 | #startup_message off 10 | 11 | #defflow on # will force screen to process ^S/^Q 12 | 13 | deflogin on 14 | #autodetach off 15 | 16 | vbell on 17 | vbell_msg " Wuff ---- Wuff!! " 18 | 19 | # all termcap entries are now duplicated as terminfo entries. 20 | # only difference should be the slightly modified syntax, and check for 21 | # terminfo entries, that are already corected in the database. 22 | # 23 | # G0 we have a SEMI-GRAPHICS-CHARACTER-MODE 24 | # WS this sequence resizes our window. 25 | # cs this sequence changes the scrollregion 26 | # hs@ we have no hardware statusline. screen will only believe that 27 | # there is a hardware status line if hs,ts,fs,ds are all set. 28 | # ts to statusline 29 | # fs from statusline 30 | # ds delete statusline 31 | # al add one line 32 | # AL add multiple lines 33 | # dl delete one line 34 | # DL delete multiple lines 35 | # ic insert one char (space) 36 | # IC insert multiple chars 37 | # nx terminal uses xon/xoff 38 | 39 | termcap facit|vt100|xterm LP:G0 40 | terminfo facit|vt100|xterm LP:G0 41 | 42 | #the vt100 description does not mention "dl". *sigh* 43 | termcap vt100 dl=5\E[M 44 | terminfo vt100 dl=5\E[M 45 | 46 | #facit's "al" / "dl" are buggy if the current / last line 47 | #contain attributes... 48 | termcap facit al=\E[L\E[K:AL@:dl@:DL@:cs=\E[%i%d;%dr:ic@ 49 | terminfo facit al=\E[L\E[K:AL@:dl@:DL@:cs=\E[%i%p1%d;%p2%dr:ic@ 50 | 51 | #make sun termcap/info better 52 | termcap sun 'up=^K:AL=\E[%dL:DL=\E[%dM:UP=\E[%dA:DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:IC=\E[%d@:WS=1000\E[8;%d;%dt' 53 | terminfo sun 'up=^K:AL=\E[%p1%dL:DL=\E[%p1%dM:UP=\E[%p1%dA:DO=\E[%p1%dB:LE=\E[%p1%dD:RI=\E[%p1%dC:IC=\E[%p1%d@:WS=\E[8;%p1%d;%p2%dt$<1000>' 54 | 55 | #xterm understands both im/ic and doesn't have a status line. 56 | #Note: Do not specify im and ic in the real termcap/info file as 57 | #some programs (e.g. vi) will (no,no, may (jw)) not work anymore. 58 | termcap xterm|fptwist hs@:cs=\E[%i%d;%dr:im=\E[4h:ei=\E[4l 59 | terminfo xterm|fptwist hs@:cs=\E[%i%p1%d;%p2%dr:im=\E[4h:ei=\E[4l 60 | 61 | # Long time I had this in my private screenrc file. But many people 62 | # seem to want it (jw): 63 | # we do not want the width to change to 80 characters on startup: 64 | # on suns, /etc/termcap has :is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l: 65 | termcap xterm 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l' 66 | terminfo xterm 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l' 67 | 68 | # 69 | # Do not use xterms alternate window buffer. 70 | # This one would not add lines to the scrollback buffer. 71 | #termcap xterm|xterms|xs ti=\E7\E[?47l 72 | #terminfo xterm|xterms|xs ti=\E7\E[?47l 73 | 74 | #make hp700 termcap/info better 75 | termcap hp700 'Z0=\E[?3h:Z1=\E[?3l:hs:ts=\E[62"p\E[0$~\E[2$~\E[1$}:fs=\E[0}\E[61"p:ds=\E[62"p\E[1$~\E[61"p:ic@' 76 | terminfo hp700 'Z0=\E[?3h:Z1=\E[?3l:hs:ts=\E[62"p\E[0$~\E[2$~\E[1$}:fs=\E[0}\E[61"p:ds=\E[62"p\E[1$~\E[61"p:ic@' 77 | 78 | #wyse-75-42 must have defflow control (xo = "terminal uses xon/xoff") 79 | #(nowadays: nx = padding doesn't work, have to use xon/off) 80 | #essential to have it here, as this is a slow terminal. 81 | termcap wy75-42 nx:xo:Z0=\E[?3h\E[31h:Z1=\E[?3l\E[31h 82 | terminfo wy75-42 nx:xo:Z0=\E[?3h\E[31h:Z1=\E[?3l\E[31h 83 | 84 | #remove some stupid / dangerous key bindings 85 | bind ^k 86 | #bind L 87 | bind ^\ 88 | #make them better 89 | bind \\ quit 90 | bind K kill 91 | bind I login on 92 | bind O login off 93 | bind } history 94 | 95 | -------------------------------------------------------------------------------- /resources/etc/ttys: -------------------------------------------------------------------------------- 1 | # 2 | # @(#)ttys 5.2 (Berkeley) 6/10/93 3 | # 4 | # name getty type status comments 5 | # 6 | console "/usr/libexec/getty std.57600" vt100 off secure 7 | #tahoe's only 8 | #remote "/usr/libexec/getty std.1200" pt on # diagnostics 9 | 10 | # The tty.serial entry initializes the serial port (if any) for use as a 11 | # terminal (enabling logons over serial). If marked secure, the serial 12 | # port will allow root logons. 13 | # To make the serial port available for outbound 14 | # communications, the tty.serial entry should be turned off 15 | # (set the 4th field to off). 16 | tty.serial "/usr/libexec/getty serial.57600" vt100 off secure 17 | 18 | # Fax reception is off by default, use the 19 | # System Preferences panel to enable it. 20 | fax "/usr/bin/fax answer" unknown off 21 | 22 | # Hardwired lines are marked off, by default, so getty(8) 23 | # is quiet when they don't exist. 24 | tty[00-07] "/usr/libexec/getty std.9600" unknown off secure 25 | 26 | # pseudo-ttys 27 | ttyp[0x0-0xf] none network slot=36 secure 28 | ttyq[0x0-0xf] none network secure 29 | ttyr[0x0-0xf] none network secure 30 | ttys[0x0-0xf] none network secure 31 | ttyt[0x0-0xf] none network secure 32 | ttyu[0x0-0xf] none network secure 33 | ttyv[0x0-0xf] none network secure 34 | ttyw[0x0-0xf] none network secure 35 | 36 | # cloning ptys 37 | ttys[000-999] none network secure 38 | -------------------------------------------------------------------------------- /resources/restored_external.c: -------------------------------------------------------------------------------- 1 | #import 2 | #include 3 | #include 4 | #include 5 | 6 | int main(){ 7 | sleep(8); 8 | printf("****************************************************\n"); 9 | printf("****************************************************\n"); 10 | printf("*************Starting inetd and USB magic***********\n"); 11 | printf("****************************************************\n"); 12 | printf("****************************************************\n"); 13 | int pid, i; 14 | char *arg[] = {"mount_apfs","/dev/disk0s1s1","/mnt1", NULL}; // rootfs, may be empty or not. We attempt all this to stop restored_external from trying it itself and rebooting when it fucks up 15 | posix_spawn(&pid, "/System/Library/Filesystems/apfs.fs/mount_apfs",NULL, NULL, (char* const*)arg, NULL); 16 | waitpid(pid, &i, 0); 17 | char *arg2[] = {"mount_apfs","-R","/dev/disk0s1s3","/mnt7", NULL}; // XATTR volume, if sep-firmware is present this will be used to make data (user partition) mountable 18 | posix_spawn(&pid, "/System/Library/Filesystems/apfs.fs/mount_apfs",NULL, NULL, (char* const*)arg2, NULL); 19 | waitpid(pid, &i, 0); 20 | char *arg3[] = {"seputil","--gigalocker-init", NULL}; 21 | posix_spawn(&pid, "/usr/libexec/seputil",NULL, NULL, (char* const*)arg3, NULL); 22 | waitpid(pid, &i, 0); 23 | char *arg4[] = {"bash","-c","/usr/libexec/seputil --load /mnt1/usr/standalone/firmware/sep-firmware.img4 &", NULL}; // let seputil load shit, but do it in bg because if it doesn't work it will get stuck otherwise 24 | posix_spawn(&pid, "/bin/bash",NULL, NULL, (char* const*)arg4, NULL); 25 | waitpid(pid, &i, 0); 26 | sleep(5); // wait for above to complete, if it succeeds 27 | char *arg5[] = {"bash","-c","/System/Library/Filesystems/apfs.fs/mount_apfs /dev/disk0s1s2 /mnt2 &", NULL}; // data partition 28 | posix_spawn(&pid, "/bin/bash",NULL, NULL, (char* const*)arg5, NULL); 29 | waitpid(pid, &i, 0); 30 | char *arg6[] = {"bash","-c","/usr/libexec/inetd -d /private/etc/inetd.conf &", NULL}; // inetd which will (hopefully) start and manage telnetd 31 | posix_spawn(&pid, "/bin/bash",NULL, NULL, (char* const*)arg6, NULL); 32 | waitpid(pid, &i, 0); 33 | printf("\n\n\n\n"); 34 | sleep(5); 35 | char *arg7[] = {"restored_external","-server",NULL}; // run restored_external in server mode, this initializes usb/networking and enables access over iproxy 36 | posix_spawn(&pid, "/usr/local/bin/restored_external_original",NULL, NULL, (char* const*)arg7, NULL); 37 | waitpid(pid, &i, 0); 38 | sleep(99999); 39 | return 0; 40 | } 41 | --------------------------------------------------------------------------------