diff --git a/.github/workflows/pr_notification.yml b/.github/workflows/pr_notification.yml new file mode 100644 index 0000000..de44c8b --- /dev/null +++ b/.github/workflows/pr_notification.yml @@ -0,0 +1,12 @@ +name: Pull Request Notification + +on: + pull_request_target: + types: + - opened + +jobs: + notify: + uses: KeyAuth/.github/.github/workflows/pr_notification_global.yml@main + secrets: + DISCORD_PR: ${{ secrets.DISCORD_PR }} diff --git a/.gitignore b/.gitignore index c8b241f..ea4bcae 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -target/* \ No newline at end of file +target/* +.idea/* \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 997c01f..13c129c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,18 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "aes" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "495ee669413bfbe9e8cace80f4d3d78e6d8c8d99579f97fb93bde351b185f2d4" -dependencies = [ - "cfg-if 1.0.0", - "cipher", - "cpufeatures", - "opaque-debug", -] - [[package]] name = "aho-corasick" version = "0.7.15" @@ -25,9 +13,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base16" @@ -37,9 +25,9 @@ checksum = "d27c3610c36aee21ce8ac510e6224498de4228ad772a171ed65643a24693a5a8" [[package]] name = "base64" -version = "0.13.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" [[package]] name = "bitflags" @@ -47,22 +35,6 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -[[package]] -name = "block-modes" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cb03d1bed155d89dce0f845b7899b18a9a163e148fd004e1c28421a783e2d8e" -dependencies = [ - "block-padding", - "cipher", -] - -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - [[package]] name = "bumpalo" version = "3.4.0" @@ -87,6 +59,12 @@ version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + [[package]] name = "cfg-if" version = "0.1.10" @@ -100,12 +78,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "cipher" -version = "0.3.0" +name = "combine" +version = "4.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" dependencies = [ - "generic-array", + "bytes 1.0.1", + "memchr", ] [[package]] @@ -125,12 +104,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" [[package]] -name = "cpufeatures" -version = "0.1.4" +name = "cty" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" + +[[package]] +name = "dirs" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed00c67cb5d0a7d64a44f6ad2668db7e7530311dd53ea79bcd4fb022c64911c8" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ "libc", + "redox_users", + "winapi", ] [[package]] @@ -173,12 +169,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - [[package]] name = "futures-channel" version = "0.3.8" @@ -230,22 +220,6 @@ dependencies = [ "slab", ] -[[package]] -name = "gcc" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" - -[[package]] -name = "generic-array" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" -dependencies = [ - "typenum", - "version_check", -] - [[package]] name = "getrandom" version = "0.1.15" @@ -270,9 +244,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.3" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "825343c4eef0b63f541f8903f395dc5beb362a979b5799a84062527ef1e37726" +checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" dependencies = [ "bytes 1.0.1", "fnv", @@ -302,6 +276,18 @@ dependencies = [ "libc", ] +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac-sha256" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc736091aacb31ddaa4cd5f6988b3c21e99913ac846b41f32538c5fae5d71bfe" + [[package]] name = "http" version = "0.2.1" @@ -310,7 +296,7 @@ checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" dependencies = [ "bytes 0.5.6", "fnv", - "itoa", + "itoa 0.4.6", ] [[package]] @@ -326,9 +312,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.4.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" @@ -338,9 +324,9 @@ checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440" [[package]] name = "hyper" -version = "0.14.8" +version = "0.14.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3f71a7eea53a3f8257a7b4795373ff886397178cd634430ea94e12d7fe4fe34" +checksum = "5e011372fa0b68db8350aa7a248930ecc7839bf46d8485577d69f117a75f164c" dependencies = [ "bytes 1.0.1", "futures-channel", @@ -351,8 +337,8 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa", - "pin-project", + "itoa 1.0.5", + "pin-project-lite", "socket2", "tokio", "tower-service", @@ -406,6 +392,32 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" +[[package]] +name = "itoa" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" + +[[package]] +name = "jni" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "039022cdf4d7b1cf548d31f60ae783138e5fd42013f6271049d7df7afadef96c" +dependencies = [ + "cesu8", + "combine", + "jni-sys", + "log", + "thiserror", + "walkdir", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + [[package]] name = "js-sys" version = "0.3.46" @@ -417,21 +429,29 @@ dependencies = [ [[package]] name = "keyauth" -version = "0.3.0" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf5ec8e7a524a25c44519cdd4f018e8f85c56c41fb1180ccd9976a3dbb8f910f" dependencies = [ - "aes", "base16", - "block-modes", + "hex", + "hmac-sha256", "machine_uuid", - "obfstr", "reqwest", - "rust-crypto", "serde", "serde_json", "uuid", "webbrowser", ] +[[package]] +name = "keyauth-loader" +version = "1.0.0" +dependencies = [ + "keyauth", + "obfstr", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -440,9 +460,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.97" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "log" @@ -462,6 +482,15 @@ dependencies = [ "regex", ] +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", +] + [[package]] name = "matches" version = "0.1.8" @@ -482,31 +511,21 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] name = "mio" -version = "0.7.13" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", - "miow", - "ntapi", - "winapi", -] - -[[package]] -name = "miow" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" -dependencies = [ - "winapi", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.45.0", ] [[package]] name = "native-tls" -version = "0.2.7" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" dependencies = [ "lazy_static", "libc", @@ -521,13 +540,10 @@ dependencies = [ ] [[package]] -name = "ntapi" -version = "0.3.6" +name = "ndk-context" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" -dependencies = [ - "winapi", -] +checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" [[package]] name = "num_cpus" @@ -546,16 +562,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b2b2cbbfd8defa51ff24450a61d73b3ff3e158484ddd274a883e886e6fbaa78" [[package]] -name = "once_cell" -version = "1.5.2" +name = "objc" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +dependencies = [ + "malloc_buf", +] [[package]] -name = "opaque-debug" -version = "0.3.0" +name = "once_cell" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "openssl" @@ -618,9 +637,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.0" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" [[package]] name = "pin-utils" @@ -658,29 +677,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.3.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" -dependencies = [ - "libc", - "rand 0.4.6", -] - -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi", -] - [[package]] name = "rand" version = "0.7.3" @@ -690,7 +686,7 @@ dependencies = [ "getrandom 0.1.15", "libc", "rand_chacha", - "rand_core 0.5.1", + "rand_core", "rand_hc", ] @@ -701,24 +697,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.5.1" @@ -734,16 +715,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core 0.5.1", + "rand_core", ] [[package]] -name = "rdrand" -version = "0.4.0" +name = "raw-window-handle" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +checksum = "ed7e3d950b66e19e0c372f3fa3fbbcf85b1746b571f74e0c2af6042a5c93420a" dependencies = [ - "rand_core 0.3.1", + "cty", ] [[package]] @@ -752,6 +733,26 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom 0.2.3", + "redox_syscall 0.2.16", + "thiserror", +] + [[package]] name = "regex" version = "1.4.2" @@ -781,31 +782,34 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.3" +version = "0.11.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2296f2fac53979e8ccbc4a1136b25dcefd37be9ed7e4a1f6b05a6029c84ff124" +checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9" dependencies = [ "base64", "bytes 1.0.1", "encoding_rs", "futures-core", "futures-util", + "h2", "http", "http-body", "hyper", "hyper-tls", "ipnet", "js-sys", - "lazy_static", "log", "mime", "native-tls", + "once_cell", "percent-encoding", "pin-project-lite", "serde", + "serde_json", "serde_urlencoded", "tokio", "tokio-native-tls", + "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", @@ -813,31 +817,21 @@ dependencies = [ "winreg", ] -[[package]] -name = "rust-crypto" -version = "0.2.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" -dependencies = [ - "gcc", - "libc", - "rand 0.3.23", - "rustc-serialize", - "time", -] - -[[package]] -name = "rustc-serialize" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" - [[package]] name = "ryu" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "schannel" version = "0.1.19" @@ -893,23 +887,23 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.64" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" dependencies = [ - "itoa", + "itoa 1.0.5", "ryu", "serde", ] [[package]] name = "serde_urlencoded" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa", + "itoa 1.0.5", "ryu", "serde", ] @@ -922,9 +916,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] name = "socket2" -version = "0.4.0" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" dependencies = [ "libc", "winapi", @@ -949,30 +943,39 @@ checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" dependencies = [ "cfg-if 0.1.10", "libc", - "rand 0.7.3", - "redox_syscall", + "rand", + "redox_syscall 0.1.57", "remove_dir_all", "winapi", ] [[package]] -name = "thread_local" -version = "1.0.1" +name = "thiserror" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" dependencies = [ - "lazy_static", + "thiserror-impl", ] [[package]] -name = "time" -version = "0.1.44" +name = "thiserror-impl" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +dependencies = [ + "lazy_static", ] [[package]] @@ -992,9 +995,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.7.1" +version = "1.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fb2ed024293bb19f7a5dc54fe83bf86532a44c12a2bb8ba40d64a4509395ca2" +checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" dependencies = [ "autocfg", "bytes 1.0.1", @@ -1003,7 +1006,8 @@ dependencies = [ "mio", "num_cpus", "pin-project-lite", - "winapi", + "socket2", + "windows-sys 0.42.0", ] [[package]] @@ -1018,16 +1022,16 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.6.7" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1caa0b0c8d94a049db56b5acf8cba99dc0623aab1b26d5b5f5e2d945846b3592" +checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" dependencies = [ "bytes 1.0.1", "futures-core", "futures-sink", - "log", "pin-project-lite", "tokio", + "tracing", ] [[package]] @@ -1038,9 +1042,9 @@ checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" [[package]] name = "tracing" -version = "0.1.22" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if 1.0.0", "pin-project-lite", @@ -1049,11 +1053,11 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.17" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] @@ -1062,12 +1066,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" -[[package]] -name = "typenum" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" - [[package]] name = "unicode-bidi" version = "0.3.4" @@ -1106,9 +1104,9 @@ dependencies = [ [[package]] name = "uuid" -version = "0.8.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79" dependencies = [ "getrandom 0.2.3", ] @@ -1120,10 +1118,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" [[package]] -name = "version_check" -version = "0.9.2" +name = "walkdir" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] [[package]] name = "want" @@ -1147,6 +1150,12 @@ version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wasm-bindgen" version = "0.2.69" @@ -1154,8 +1163,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3cd364751395ca0f68cafb17666eee36b63077fb5ecd972bbcd74c90c4bf736e" dependencies = [ "cfg-if 1.0.0", - "serde", - "serde_json", "wasm-bindgen-macro", ] @@ -1227,21 +1234,21 @@ dependencies = [ [[package]] name = "webbrowser" -version = "0.5.5" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecad156490d6b620308ed411cfee90d280b3cbd13e189ea0d3fada8acc89158a" +checksum = "97d1fa1e5c829b2bf9eb1e28fb950248b797cd6a04866fbdfa8bc31e5eef4c78" dependencies = [ + "core-foundation", + "dirs", + "jni", + "log", + "ndk-context", + "objc", + "raw-window-handle", + "url", "web-sys", - "widestring", - "winapi", ] -[[package]] -name = "widestring" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c" - [[package]] name = "winapi" version = "0.3.9" @@ -1258,17 +1265,107 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" + [[package]] name = "winreg" -version = "0.7.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" dependencies = [ "winapi", ] diff --git a/Cargo.toml b/Cargo.toml index 075209f..0886f04 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,20 +1,11 @@ [package] -authors = ["zegevlier ", "mazkdevf "] -edition = "2018" -name = "keyauth" -version = "0.5.0" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +authors = ["EBSmash ", "mazkdevf "] +edition = "2021" +name = "keyauth-loader" +version = "1.0.0" [dependencies] -aes = "0.7.4" -base16 = "0.2.1" -block-modes = "0.8.1" -machine_uuid = "0.1.0" -obfstr = "0.3.0" -reqwest = {version = "0.11.3", features = ["blocking"]} -rust-crypto = "0.2.36" -serde = {version = "1.0.126", features = ["derive"]} -serde_json = "1.0.64" -uuid = {version = "0.8.2", features = ["v4"]} -webbrowser = "0.5.5" +keyauth = "1.2.0" +#keyauth = { version = "1.0.3", features = ["seller", "v1_1], default-features = false } +obfstr = "0.3.0" # sting only obfuscation +#goldberg = "0.1.0" # for obfuscation diff --git a/LICENSE b/LICENSE index 5849551..809108b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,93 @@ -MIT License - -Copyright (c) 2022 KeyAuth - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +Elastic License 2.0 + +URL: https://www.elastic.co/licensing/elastic-license + +## Acceptance + +By using the software, you agree to all of the terms and conditions below. + +## Copyright License + +The licensor grants you a non-exclusive, royalty-free, worldwide, +non-sublicensable, non-transferable license to use, copy, distribute, make +available, and prepare derivative works of the software, in each case subject to +the limitations and conditions below. + +## Limitations + +You may not provide the software to third parties as a hosted or managed +service, where the service provides users with access to any substantial set of +the features or functionality of the software. + +You may not move, change, disable, or circumvent the license key functionality +in the software, and you may not remove or obscure any functionality in the +software that is protected by the license key. + +You may not alter, remove, or obscure any licensing, copyright, or other notices +of the licensor in the software. Any use of the licensor’s trademarks is subject +to applicable law. + +## Patents + +The licensor grants you a license, under any patent claims the licensor can +license, or becomes able to license, to make, have made, use, sell, offer for +sale, import and have imported the software, in each case subject to the +limitations and conditions in this license. This license does not cover any +patent claims that you cause to be infringed by modifications or additions to +the software. If you or your company make any written claim that the software +infringes or contributes to infringement of any patent, your patent license for +the software granted under these terms ends immediately. If your company makes +such a claim, your patent license ends immediately for work on behalf of your +company. + +## Notices + +You must ensure that anyone who gets a copy of any part of the software from you +also gets a copy of these terms. + +If you modify the software, you must include in any modified copies of the +software prominent notices stating that you have modified the software. + +## No Other Rights + +These terms do not imply any licenses other than those expressly granted in +these terms. + +## Termination + +If you use the software in violation of these terms, such use is not licensed, +and your licenses will automatically terminate. If the licensor provides you +with a notice of your violation, and you cease all violation of this license no +later than 30 days after you receive that notice, your licenses will be +reinstated retroactively. However, if you violate these terms after such +reinstatement, any additional violation of these terms will cause your licenses +to terminate automatically and permanently. + +## No Liability + +*As far as the law allows, the software comes as is, without any warranty or +condition, and the licensor will not be liable to you for any damages arising +out of these terms or the use or nature of the software, under any kind of +legal claim.* + +## Definitions + +The **licensor** is the entity offering these terms, and the **software** is the +software the licensor makes available under these terms, including any portion +of it. + +**you** refers to the individual or entity agreeing to these terms. + +**your company** is any legal entity, sole proprietorship, or other kind of +organization that you work for, plus all organizations that have control over, +are under the control of, or are under common control with that +organization. **control** means ownership of substantially all the assets of an +entity, or the power to direct its management and policies by vote, contract, or +otherwise. Control can be direct or indirect. + +**your licenses** are all the licenses granted to you for the software under +these terms. + +**use** means anything you do with the software requiring one of your licenses. + +**trademark** means trademarks, service marks, and similar rights. diff --git a/README.md b/README.md index 42a343d..04c1c02 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,43 @@ # KeyAuth-Rust-Example -KeyAuth Rust Example For The https://keyauth.win Authentication system. +KeyAuth Rust example SDK for https://keyauth.cc license key API auth. -Update the values in main.rs and you're ready to go! +Update the values in the `main.rs` file and you're ready to go! -### **Credits** -Original Version Creator: zegevlier#2959 +## **Bugs** -2022 Version Creator: mazkdevf - [Github](https://github.com/mazk5145) +If you have any issues with the underling library make an issue on the library's [Github](https://github.com/D0A1V2I3D/keyauth-rust) +[Old library](https://github.com/KeyAuth/KeyAuth-Rust-Example/tree/backupoldapi) -**What is KeyAuth?** +However, we do **NOT** provide support for adding KeyAuth to your project. If you can't figure this out you should use Google or YouTube to learn more about the programming language you want to sell a program in. -KeyAuth is an Open source authentication system with cloud hosting plans as well. Client SDKs available for C++, C#, Python, Rust, PHP, and VB.NET. KeyAuth has several unique features such as memory streaming, webhook function where you can send requests to API without leaking the API, discord webhook notifications, ban the user securely through the application at your discretion. Feel free to join https://keyauth.win/discord/ if you have questions or suggestions. +## Copyright License + +KeyAuth is licensed under **Elastic License 2.0** + +* You may not provide the software to third parties as a hosted or managed +service, where the service provides users with access to any substantial set of +the features or functionality of the software. + +* You may not move, change, disable, or circumvent the license key functionality +in the software, and you may not remove or obscure any functionality in the +software that is protected by the license key. + +* You may not alter, remove, or obscure any licensing, copyright, or other notices +of the licensor in the software. Any use of the licensor’s trademarks is subject +to applicable law. + +Thank you for your compliance, we work hard on the development of KeyAuth and do not appreciate our copyright being infringed. + +## **Author** + +mazkdevf - [Github](https://github.com/mazkdevf) +
+davidon-top - [GitHub](https://github.com/davidon-top) + +## **What is KeyAuth?** + +KeyAuth is an Open source authentication system with cloud hosting plans as well. Client SDKs available for [C#](https://github.com/KeyAuth/KeyAuth-CSHARP-Example), [C++](https://github.com/KeyAuth/KeyAuth-CPP-Example), [Python](https://github.com/KeyAuth/KeyAuth-Python-Example), [Java](https://github.com/KeyAuth-Archive/KeyAuth-JAVA-api), [JavaScript](https://github.com/mazkdevf/KeyAuth-JS-Example), [VB.NET](https://github.com/KeyAuth/KeyAuth-VB-Example), [PHP](https://github.com/KeyAuth/KeyAuth-PHP-Example), [Rust](https://github.com/KeyAuth/KeyAuth-Rust-Example), [Go](https://github.com/mazkdevf/KeyAuth-Go-Example), [Lua](https://github.com/mazkdevf/KeyAuth-Lua-Examples), [Ruby](https://github.com/mazkdevf/KeyAuth-Ruby-Example), and [Perl](https://github.com/mazkdevf/KeyAuth-Perl-Example). KeyAuth has several unique features such as memory streaming, webhook function where you can send requests to API without leaking the API, discord webhook notifications, ban the user securely through the application at your discretion. Feel free to join https://t.me/keyauth if you have questions or suggestions. + +> [!TIP] +> https://vaultcord.com FREE Discord bot to Backup server, members, channels, messages & more. Custom verify page, block alt accounts, VPNs & more. diff --git a/src/keyauth.rs b/src/keyauth.rs deleted file mode 100644 index 329f0a2..0000000 --- a/src/keyauth.rs +++ /dev/null @@ -1,579 +0,0 @@ -use std::collections::HashMap; - -use base16::{decode, encode_lower}; -use crypto::{digest::Digest, sha2::Sha256}; -use reqwest::blocking::Client; -use uuid::Uuid; - -use aes::Aes256; -use block_modes::block_padding::Pkcs7; -use block_modes::{BlockMode, Cbc}; - -const BASE_URL: &str = "https://keyauth.win/api/1.0/"; - -type Aes256Cbc = Cbc; - -pub struct KeyauthApi { - name: String, - owner_id: String, - secret: String, - version: String, - enckey: String, - session_id: String, - pub numKeys: String, - pub numOnlineUsers: String, - pub numUsers: String, - pub appVersion: String, - pub customerPanelLink: String, - pub username: String, - pub ip: String, - pub hwid: String, - pub createDate: String, - pub LastLogin: String, - pub subscription: String, - pub message: String, - pub success: bool, - pub blackListed: bool, - pub response: String, -} - -impl KeyauthApi { - pub fn new(name: &str, owner_id: &str, secret: &str, version: &str) -> Self { - Self { - name: name.to_string(), - owner_id: owner_id.to_string(), - secret: secret.to_string(), - version: version.to_string(), - enckey: String::new(), - session_id: String::new(), - numKeys: String::new(), - numOnlineUsers: String::new(), - numUsers: String::new(), - appVersion: version.to_string(), - customerPanelLink: String::new(), - username: String::new(), - ip: String::new(), - hwid: Self::get_hwid(), - createDate: String::new(), - LastLogin: String::new(), - subscription: String::new(), - message: String::new(), - success: false, - blackListed: false, - response: String::new(), - } - } - - pub fn init(&mut self) -> Result<(), String> { - let init_iv = Self::gen_init_iv(); - self.enckey = Self::gen_init_iv(); - - let mut data = HashMap::new(); - data.insert("type", encode_lower(b"init")); - data.insert( - "ver", - Encryption::encrypt(&self.version, &self.secret, &init_iv), - ); - data.insert( - "enckey", - Encryption::encrypt(&self.enckey, &self.secret, &init_iv), - ); - data.insert("name", encode_lower(self.name.as_bytes())); - data.insert("ownerid", encode_lower(self.owner_id.as_bytes())); - data.insert("init_iv", init_iv.to_string()); - - let req = Self::make_req(data); - let response = req.text().unwrap(); - - if response == "KeyAuth_Invalid" { - return Err("The application doesn't exist".to_string()); - } - - let response = Encryption::decrypt(response, &self.secret, &init_iv); - - let json_rep: serde_json::Value = serde_json::from_str(&response).unwrap(); - - if json_rep["success"].as_bool().unwrap() { - self.session_id = json_rep["sessionid"].as_str().unwrap().to_string(); - self.numKeys = json_rep["appinfo"]["numKeys"].as_str().unwrap().to_string(); - self.numOnlineUsers = json_rep["appinfo"]["numOnlineUsers"] - .as_str() - .unwrap() - .to_string(); - self.numUsers = json_rep["appinfo"]["numUsers"] - .as_str() - .unwrap() - .to_string(); - self.customerPanelLink = json_rep["appinfo"]["customerPanelLink"] - .as_str() - .unwrap() - .to_string(); - Ok(()) - } else { - if json_rep["message"].as_str().unwrap() == "invalidver" { - let download_url = json_rep["download"].as_str().unwrap(); - if !download_url.is_empty() { - webbrowser::open(download_url).unwrap(); - } - } - Err(json_rep["message"].as_str().unwrap().to_string()) - } - } - - pub fn register( - &mut self, - username: String, - password: String, - license: String, - hwid: Option, - ) -> Result<(), String> { - let init_iv = Self::gen_init_iv(); - - let hwid = match hwid { - Some(hwid) => hwid, - None => Self::get_hwid(), - }; - - let mut data = HashMap::new(); - data.insert("type", encode_lower(b"register")); - data.insert( - "username", - Encryption::encrypt(&username, &self.enckey, &init_iv), - ); - data.insert( - "pass", - Encryption::encrypt(&password, &self.enckey, &init_iv), - ); - data.insert("key", Encryption::encrypt(&license, &self.enckey, &init_iv)); - data.insert("hwid", Encryption::encrypt(&hwid, &self.enckey, &init_iv)); - data.insert("sessionid", encode_lower(self.session_id.as_bytes())); - data.insert("name", encode_lower(self.name.as_bytes())); - data.insert("ownerid", encode_lower(self.owner_id.as_bytes())); - data.insert("init_iv", init_iv.to_string()); - - let req = Self::make_req(data); - let response = req.text().unwrap(); - - let response = Encryption::decrypt(response, &self.enckey, &init_iv); - - let json_rep: serde_json::Value = serde_json::from_str(&response).unwrap(); - - if json_rep["success"].as_bool().unwrap() { - self.username = json_rep["info"]["username"].as_str().unwrap().to_string(); - self.ip = json_rep["info"]["ip"].as_str().unwrap().to_string(); - self.hwid = json_rep["info"]["hwid"].as_str().unwrap().to_string(); - self.createDate = json_rep["info"]["createdate"].as_str().unwrap().to_string(); - self.LastLogin = json_rep["info"]["lastlogin"].as_str().unwrap().to_string(); - self.subscription = json_rep["info"]["subscriptions"][0]["subscription"] - .as_str() - .unwrap() - .to_string(); - Ok(()) - } else { - Err(json_rep["message"].as_str().unwrap().to_string()) - } - } - - pub fn upgrade(&mut self, username: String, license: String) -> Result<(), String> { - let init_iv = Self::gen_init_iv(); - - let mut data = HashMap::new(); - data.insert("type", encode_lower(b"upgrade")); - data.insert( - "username", - Encryption::encrypt(&username, &self.enckey, &init_iv), - ); - data.insert("key", Encryption::encrypt(&license, &self.enckey, &init_iv)); - data.insert("sessionid", encode_lower(self.session_id.as_bytes())); - data.insert("name", encode_lower(self.name.as_bytes())); - data.insert("ownerid", encode_lower(self.owner_id.as_bytes())); - data.insert("init_iv", init_iv.to_string()); - - let req = Self::make_req(data); - let response = req.text().unwrap(); - - let response = Encryption::decrypt(response, &self.enckey, &init_iv); - - let json_rep: serde_json::Value = serde_json::from_str(&response).unwrap(); - - if json_rep["success"].as_bool().unwrap() { - Ok(()) - } else { - Err(json_rep["message"].as_str().unwrap().to_string()) - } - } - - pub fn login( - &mut self, - username: String, - password: String, - hwid: Option, - ) -> Result<(), String> { - let init_iv = Self::gen_init_iv(); - - let hwid = match hwid { - Some(hwid) => hwid, - None => Self::get_hwid(), - }; - - let mut data = HashMap::new(); - data.insert("type", encode_lower(b"login")); - data.insert( - "username", - Encryption::encrypt(&username, &self.enckey, &init_iv), - ); - data.insert( - "pass", - Encryption::encrypt(&password, &self.enckey, &init_iv), - ); - data.insert("hwid", Encryption::encrypt(&hwid, &self.enckey, &init_iv)); - data.insert("sessionid", encode_lower(self.session_id.as_bytes())); - data.insert("name", encode_lower(self.name.as_bytes())); - data.insert("ownerid", encode_lower(self.owner_id.as_bytes())); - data.insert("init_iv", init_iv.to_string()); - - let req = Self::make_req(data); - let response = req.text().unwrap(); - - let response = Encryption::decrypt(response, &self.enckey, &init_iv); - println!("{}", response); - - let json_rep: serde_json::Value = serde_json::from_str(&response).unwrap(); - - if json_rep["success"].as_bool().unwrap() { - self.username = json_rep["info"]["username"].as_str().unwrap().to_string(); - self.ip = json_rep["info"]["ip"].as_str().unwrap().to_string(); - self.hwid = json_rep["info"]["hwid"].as_str().unwrap().to_string(); - self.createDate = json_rep["info"]["createdate"].as_str().unwrap().to_string(); - self.LastLogin = json_rep["info"]["lastlogin"].as_str().unwrap().to_string(); - self.subscription = json_rep["info"]["subscriptions"][0]["subscription"] - .as_str() - .unwrap() - .to_string(); - - Ok(()) - } else { - Err(json_rep["message"].as_str().unwrap().to_string()) - } - } - - pub fn license( - &mut self, - license: String, - hwid: Option, - ) -> Result { - let init_iv = Self::gen_init_iv(); - - let hwid = match hwid { - Some(hwid) => hwid, - None => Self::get_hwid(), - }; - - let mut data = HashMap::new(); - data.insert("type", encode_lower(b"license")); - data.insert("key", Encryption::encrypt(&license, &self.enckey, &init_iv)); - data.insert("hwid", Encryption::encrypt(&hwid, &self.enckey, &init_iv)); - data.insert("sessionid", encode_lower(self.session_id.as_bytes())); - data.insert("name", encode_lower(self.name.as_bytes())); - data.insert("ownerid", encode_lower(self.owner_id.as_bytes())); - data.insert("init_iv", init_iv.to_string()); - - let req = Self::make_req(data); - let response = req.text().unwrap(); - - let response = Encryption::decrypt(response, &self.enckey, &init_iv); - - let json_rep: serde_json::Value = serde_json::from_str(&response).unwrap(); - - if json_rep["success"].as_bool().unwrap() { - self.username = json_rep["info"]["username"].as_str().unwrap().to_string(); - self.ip = json_rep["info"]["ip"].as_str().unwrap().to_string(); - self.hwid = json_rep["info"]["hwid"].as_str().unwrap().to_string(); - self.createDate = json_rep["info"]["createdate"].as_str().unwrap().to_string(); - self.LastLogin = json_rep["info"]["lastlogin"].as_str().unwrap().to_string(); - self.subscription = json_rep["info"]["subscriptions"][0]["subscription"] - .as_str() - .unwrap() - .to_string(); - - Ok(json_rep["info"].clone()) - } else { - Err(json_rep["message"].as_str().unwrap().to_string()) - } - } - - pub fn var(&mut self, varid: String) -> Result { - let init_iv = Self::gen_init_iv(); - - let mut data = HashMap::new(); - data.insert("type", encode_lower(b"var")); - data.insert("varid", Encryption::encrypt(&varid, &self.enckey, &init_iv)); - data.insert("sessionid", encode_lower(self.session_id.as_bytes())); - data.insert("name", encode_lower(self.name.as_bytes())); - data.insert("ownerid", encode_lower(self.owner_id.as_bytes())); - data.insert("init_iv", init_iv.to_string()); - - let req = Self::make_req(data); - let response = req.text().unwrap(); - - let response = Encryption::decrypt(response, &self.enckey, &init_iv); - - let json_rep: serde_json::Value = serde_json::from_str(&response).unwrap(); - - if json_rep["success"].as_bool().unwrap() { - Ok(json_rep["message"].as_str().unwrap().to_string()) - } else { - Err(json_rep["message"].as_str().unwrap().to_string()) - } - } - - pub fn file(&mut self, fileid: String) -> Result, String> { - let init_iv = Self::gen_init_iv(); - - let mut data = HashMap::new(); - data.insert("type", encode_lower(b"file")); - data.insert( - "fileid", - Encryption::encrypt(&fileid, &self.enckey, &init_iv), - ); - data.insert("sessionid", encode_lower(self.session_id.as_bytes())); - data.insert("name", encode_lower(self.name.as_bytes())); - data.insert("ownerid", encode_lower(self.owner_id.as_bytes())); - data.insert("init_iv", init_iv.to_string()); - - let req = Self::make_req(data); - let response = req.text().unwrap(); - - let response = Encryption::decrypt(response, &self.enckey, &init_iv); - - let json_rep: serde_json::Value = serde_json::from_str(&response).unwrap(); - - if json_rep["success"].as_bool().unwrap() { - Ok(decode(json_rep["contents"].as_str().unwrap()).unwrap()) - } else { - Err(json_rep["message"].as_str().unwrap().to_string()) - } - } - - pub fn webhook(&mut self, webid: String, params: String) -> Result { - let init_iv = Self::gen_init_iv(); - - let mut data = HashMap::new(); - data.insert("type", encode_lower(b"webhook")); - data.insert("webid", Encryption::encrypt(&webid, &self.enckey, &init_iv)); - data.insert( - "params", - Encryption::encrypt(¶ms, &self.enckey, &init_iv), - ); - data.insert("sessionid", encode_lower(self.session_id.as_bytes())); - data.insert("name", encode_lower(self.name.as_bytes())); - data.insert("ownerid", encode_lower(self.owner_id.as_bytes())); - data.insert("init_iv", init_iv.to_string()); - - let req = Self::make_req(data); - let response = req.text().unwrap(); - - let response = Encryption::decrypt(response, &self.enckey, &init_iv); - - let json_rep: serde_json::Value = serde_json::from_str(&response).unwrap(); - - if json_rep["success"].as_bool().unwrap() { - Ok(json_rep["message"].as_str().unwrap().to_string()) - } else { - Err(json_rep["message"].as_str().unwrap().to_string()) - } - } - - pub fn check(&mut self) { - let init_iv = Self::gen_init_iv(); - - let mut data = HashMap::new(); - data.insert("type", encode_lower(b"check")); - data.insert("sessionid", encode_lower(self.session_id.as_bytes())); - data.insert("name", encode_lower(self.name.as_bytes())); - data.insert("ownerid", encode_lower(self.owner_id.as_bytes())); - data.insert("init_iv", init_iv.to_string()); - - let req = Self::make_req(data); - let response = req.text().unwrap(); - - let response = Encryption::decrypt(response, &self.enckey, &init_iv); - - let json_rep: serde_json::Value = serde_json::from_str(&response).unwrap(); - - self.message = json_rep["message"].as_str().unwrap().to_string(); - self.success = json_rep["success"].as_bool().unwrap(); - } - - pub fn checkBlack(&mut self) { - let init_iv = Self::gen_init_iv(); - - let hwid = Self::get_hwid(); - - let mut data = HashMap::new(); - data.insert("type", encode_lower(b"checkblacklist")); - data.insert("sessionid", encode_lower(self.session_id.as_bytes())); - data.insert("name", encode_lower(self.name.as_bytes())); - data.insert("ownerid", encode_lower(self.owner_id.as_bytes())); - data.insert("hwid", Encryption::encrypt(&hwid, &self.enckey, &init_iv)); - data.insert("init_iv", init_iv.to_string()); - - let req = Self::make_req(data); - let response = req.text().unwrap(); - - let response = Encryption::decrypt(response, &self.enckey, &init_iv); - - let json_rep: serde_json::Value = serde_json::from_str(&response).unwrap(); - - if json_rep["success"].as_bool().unwrap() { - self.blackListed = true; - } else { - self.blackListed = false; - } - } - - pub fn setvar(&mut self, varname: String, varvalue: String) { - let init_iv = Self::gen_init_iv(); - - let mut data = HashMap::new(); - data.insert("type", encode_lower(b"setvar")); - data.insert("sessionid", encode_lower(self.session_id.as_bytes())); - data.insert("name", encode_lower(self.name.as_bytes())); - data.insert("var", encode_lower(varname.as_bytes())); - data.insert("data", encode_lower(varvalue.as_bytes())); - data.insert("ownerid", encode_lower(self.owner_id.as_bytes())); - data.insert("init_iv", init_iv.to_string()); - - let req = Self::make_req(data); - let response = req.text().unwrap(); - - let response = Encryption::decrypt(response, &self.enckey, &init_iv); - - let json_rep: serde_json::Value = serde_json::from_str(&response).unwrap(); - - self.message = json_rep["message"].as_str().unwrap().to_string(); - self.success = json_rep["success"].as_bool().unwrap(); - } - - pub fn getvar(&mut self, varname: String) { - let init_iv = Self::gen_init_iv(); - - let mut data = HashMap::new(); - data.insert("type", encode_lower(b"getvar")); - data.insert("sessionid", encode_lower(self.session_id.as_bytes())); - data.insert("var", encode_lower(varname.as_bytes())); - data.insert("name", encode_lower(self.name.as_bytes())); - data.insert("ownerid", encode_lower(self.owner_id.as_bytes())); - data.insert("init_iv", init_iv.to_string()); - - let req = Self::make_req(data); - let response = req.text().unwrap(); - - let response = Encryption::decrypt(response, &self.enckey, &init_iv); - - let json_rep: serde_json::Value = serde_json::from_str(&response).unwrap(); - - if json_rep["success"].as_bool().unwrap() { - self.response = json_rep["response"].as_str().unwrap().to_string(); - } else { - self.response = json_rep["message"].as_str().unwrap().to_string(); - } - } - - pub fn log(&mut self, message: String) { - let init_iv = Self::gen_init_iv(); - - let mut data = HashMap::new(); - data.insert("type", encode_lower(b"log")); - data.insert( - "pcuser", - Encryption::encrypt(&std::env::var("username").unwrap(), &self.enckey, &init_iv), - ); - data.insert( - "message", - Encryption::encrypt(&message, &self.enckey, &init_iv), - ); - data.insert("sessionid", encode_lower(self.session_id.as_bytes())); - data.insert("name", encode_lower(self.name.as_bytes())); - data.insert("ownerid", encode_lower(self.owner_id.as_bytes())); - data.insert("init_iv", init_iv); - - Self::make_req(data); - } - - fn make_req(data: HashMap<&str, String>) -> reqwest::blocking::Response { - let client = Client::new(); - let mut data_str = String::new(); - for d in data { - data_str.push_str(&format!("{}={}&", d.0, d.1)) - } - data_str = data_str.strip_suffix('&').unwrap().to_string(); - client - .post(BASE_URL) - .body(data_str) - .header("User-Agent", "KeyAuth") - .header("content-type", "application/x-www-form-urlencoded") - .send() - .unwrap() - } - - fn get_hwid() -> String { - if cfg!(windows) { - machine_uuid::get() - } else { - "None".to_string() - } - } - - fn gen_init_iv() -> String { - let session_iv = Uuid::new_v4().to_simple().to_string()[..8].to_string(); - let mut hasher = Sha256::new(); - hasher.input(session_iv.as_bytes()); - hasher.result_str() - } -} - -struct Encryption; -impl Encryption { - fn encrypt_string(plain_text: &[u8], key: &[u8], iv: &[u8]) -> String { - let mut buffer = [0u8; 128]; - let pos = plain_text.len(); - buffer[..pos].copy_from_slice(plain_text); - let cipher = Aes256Cbc::new_from_slices(&key, &iv).unwrap(); - let ciphertext = cipher.encrypt(&mut buffer, pos).unwrap(); - encode_lower(ciphertext) - } - - fn decrypt_string(cipher_text: &[u8], key: &[u8], iv: &[u8]) -> Vec { - let cipher_text = decode(cipher_text).unwrap(); - let cipher = Aes256Cbc::new_from_slices(&key, &iv).unwrap(); - cipher.decrypt_vec(&cipher_text).unwrap() - } - - fn encrypt(message: &str, enc_key: &str, iv: &str) -> String { - let mut hasher = Sha256::new(); - hasher.input(enc_key.as_bytes()); - let key: String = hasher.result_str()[..32].to_owned(); - - let mut hasher = Sha256::new(); - hasher.input(iv.as_bytes()); - let iv: String = hasher.result_str()[..16].to_owned(); - Encryption::encrypt_string(message.as_bytes(), key.as_bytes(), iv.as_bytes()) - } - - fn decrypt(message: String, enc_key: &str, iv: &str) -> String { - let mut hasher = Sha256::new(); - hasher.input(enc_key.as_bytes()); - let key: String = hasher.result_str()[..32].to_owned(); - - let mut hasher = Sha256::new(); - hasher.input(iv.as_bytes()); - let iv: String = hasher.result_str()[..16].to_owned(); - String::from_utf8(Encryption::decrypt_string( - message.as_bytes(), - key.as_bytes(), - iv.as_bytes(), - )) - .unwrap() - } -} diff --git a/src/main.rs b/src/main.rs index 9b88a20..add4896 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,206 +1,20 @@ -mod keyauth; -use simple_user_input::get_input; -use std::process; - fn main() { - let mut keyauthapp = keyauth::KeyauthApi::new( - "", // Application name - "", // Application OwnerID - obfstr::obfstr!(""), // Application Secret - "", // Application Version - ); - - match keyauthapp.init() { - Ok(_) => println!("Initialized"), - Err(msg) => { - println!("\n\n Error: {}", msg); - return; - } - }; - - keyauthapp.check(); - keyauthapp.checkBlack(); - println!( - " -- - Application Data: - Number of users: {} - Number of online users: {} - Number of keys: {} - Application Version: {} - Customer panel link: {} - - Session Validated? {} - BlackListed? {} -", - keyauthapp.numKeys.to_string(), - keyauthapp.numOnlineUsers.to_string(), - keyauthapp.numUsers.to_string(), - keyauthapp.appVersion.to_string(), - keyauthapp.customerPanelLink.to_string(), - keyauthapp.message.to_string(), - keyauthapp.blackListed.to_string() - ); - - let input: String = get_input( - " - 1 Login - 2 Register - 3 Upgrade - 4 License - - Your Choice: ", - ); - - if input == "1" { - let UserName: String = get_input(" Username: "); - let PassWord: String = get_input(" Password: "); - - match keyauthapp.login(UserName, PassWord, None) { - Ok(_) => {} - Err(msg) => { - println!("Status: {}", msg); - process::exit(0); - } - } - } else if input == "2" { - let UserName: String = get_input(" Username: "); - let PassWord: String = get_input(" Password: "); - let License: String = get_input(" License: "); - - match keyauthapp.register(UserName, PassWord, License, None) { - Ok(_) => {} - Err(msg) => { - println!("Status: {}", msg); - process::exit(0); - } - } - } else if input == "3" { - let UserName: String = get_input(" Username: "); - let License: String = get_input(" License: "); - - match keyauthapp.upgrade(UserName, License) { - Ok(_) => {} - Err(msg) => { - println!("Status: {}", msg); - process::exit(0); - } - } - } else if input == "4" { - let License: String = get_input(" License: "); - - match keyauthapp.license(License, None) { - Ok(_) => {} - Err(msg) => { - println!("Status: {}", msg); - process::exit(0); - } - } - } else { - println!(" Wrong Choice!"); - process::exit(0); - } - - keyauthapp.check(); - keyauthapp.checkBlack(); - println!( - " --Logged in! - - Username: {} - IP address: {} - Hardware-Id: {} - Created at: {} - Last Login: {} - Subscription: {} - - Session Validated? {} - BlackListed? {} - -", - keyauthapp.username.to_string(), - keyauthapp.ip.to_string(), - keyauthapp.hwid.to_string(), - keyauthapp.createDate.to_string(), - keyauthapp.LastLogin.to_string(), - keyauthapp.subscription.to_string(), - keyauthapp.message.to_string(), - keyauthapp.blackListed.to_string() + let mut keyauthapp = keyauth::v1_2::KeyauthApi::new( + "example", + "JjPMBVlIOd", + "db40d586f4b189e04e5c18c3c94b7e72221be3f6551995adc05236948d1762bc", + "1.0", + "https://keyauth.cc/api/1.2/", ); - println!(" Closing in 10 seconds..."); -} - -mod simple_user_input { - use std::io; - pub fn get_input(prompt: &str) -> String { - println!("{}", prompt); - let mut input = String::new(); - match io::stdin().read_line(&mut input) { - Ok(_goes_into_input_above) => {} - Err(_no_updates_is_fine) => {} - } - input.trim().to_string() - } -} - -/* -match keyauthapp.register(username.clone(), password.clone(), key, None) { - Ok(_) => println!("Registered"), - Err(msg) => { - println!("Error: {}", msg); - return; - } -} - -match keyauthapp.login(username.clone(), password, None) { - Ok(_) => println!("Logged in"), - Err(msg) => { - println!("Error: {}", msg); - return; - } -} - -match keyauthapp.license(key2, None) { - Ok(_) => println!("License works"), - Err(msg) => { - println!("Error: {}", msg); - return; - } -} - -match keyauthapp.upgrade(username, key3) { - Ok(_) => println!("Upgrade works"), - Err(msg) => { - println!("Error: {}", msg); - return; - } -} - -match keyauthapp.var(varid) { - Ok(var) => println!("VarID works: {}", var), - Err(msg) => { - println!("Error: {}", msg); - return; - } -} + // None or Some(apphash) + // we call unwrap() because if the response success = false, it returns an error with the error message + keyauthapp.init(None).unwrap(); -match keyauthapp.file(fileid) { - Ok(contents) => println!("FileID works: {}", String::from_utf8_lossy(&contents)), - Err(msg) => { - println!("Error: {}", msg); - return; - } -} + // None will auto generate hwid, if you want to use your own hwid system then use Some(hwid) + //auth.register("some_username".to_string(), "some_password_from_user".to_string(), "7F64WM-TP3I4H-6NY0QI-164KGY-WP5CHF-EBFG30".to_string(), None).unwrap(); + // again None will autogenerate hwid + keyauthapp.login("some_username".to_string(), "some_password_from_user".to_string(), None).unwrap(); -match keyauthapp.webhook(webid, params) { - Ok(contents) => println!("Web works: {}", contents), - Err(msg) => { - println!("Error: {}", msg); - return; - } + // for more functions see the docs https://docs.rs/keyauth/latest/keyauth/ } - -keyauthapp.log("Log message works as well!".to_string()); -println!("Log seems to work as well!"); -*/