Skip to content
This repository has been archived by the owner on Aug 29, 2021. It is now read-only.

Commit

Permalink
弃用socket 通过命令行交互调用函数 其他优化
Browse files Browse the repository at this point in the history
  • Loading branch information
xhlove committed Jul 31, 2021
1 parent a2b6c48 commit e643b4f
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 85 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@
使用mingw64编译

```bash
g++ -o main -pthread -std=gnu++0x -static main.cpp misc.cpp codelift.cpp algebra.cpp allocate.cpp integer.cpp Socket.cpp -lws2_32
g++ -o main -pthread -std=gnu++0x -static main.cpp misc.cpp codelift.cpp algebra.cpp allocate.cpp integer.cpp -lws2_32
```

# **注意 & Attention**

以下报错表明session配置过期(session config is expired)

- `Could not remove padding, probably invalid key`

# 打包

```bash
Expand Down
112 changes: 61 additions & 51 deletions guesskey/main.cpp
Original file line number Diff line number Diff line change
@@ -1,70 +1,80 @@
#include <iostream>
// #include <string>
#include <cstring>

#include "Socket.h"
#include <process.h>
// #include "Socket.h"
// #include <process.h>
#include "codelift.h"

using namespace std;

// int main(int argc,char **argv)
// {
// // cout << "input:" << argv[1] << endl;
// const char *result;
// string flag = argv[1];
// string input = argv[2];
// const char *p = input.c_str();
// // cout << "Hello, world!" << endl;
// if (flag == "guessInput"){
// result = guessInput(p);
// }
// else{
// result = getDeoaep(p);
// }

// cout << result << endl;
// // cout << "Hello, world!" << endl;
// return 0;
// }
int main(int argc,char **argv)
{
std::string input;
const char *result = "err";
std::string flag_guessInput = "guessInput";
std::string flag_getDeoaep = "getDeoaep";

unsigned __stdcall Answer(void* a) {
Socket* s = (Socket*) a;
std::string flag = "guessInput";
while (1) {
std::string msg = s->ReceiveLine();
// 去除末尾的换行符
msg = msg.substr(0, msg.size() - 1);
while (1){
cin >> input;
// cout << "The value you entered is " << input << endl;
// 以|分割得到要调用的方法名和具体参数
int pos = msg.find_first_of('|');
std::string func_name = msg.substr(0, pos);
std::string func_arg = msg.substr(pos + 1);
const char *result = "err";
int pos = input.find_first_of('|');
std::string func_name = input.substr(0, pos);
std::string func_arg = input.substr(pos + 1);
// 调用函数
if(strcmp(func_name.c_str(), flag.c_str()) == 0){
if(strcmp(func_name.c_str(), flag_guessInput.c_str()) == 0){
result = guessInput(func_arg.c_str());
}
else{
else if(strcmp(func_name.c_str(), flag_getDeoaep.c_str()) == 0){
result = getDeoaep(func_arg.c_str());
}
if (msg.empty()){
else{
break;
}
s->SendLine(result);
cout << result << endl;
}
delete s;

return 0;
}

int main(int argc,char **argv)
{
std::string::size_type sz;
int port = std::stoi(argv[1], &sz);
cout << "listen at:" << port << endl;
SocketServer in(port, 10);
while (1) {
Socket* s=in.Accept();
unsigned ret;
_beginthreadex(0,0,Answer,(void*) s,0,&ret);
}
return 0;
}
// unsigned __stdcall Answer(void* a) {
// Socket* s = (Socket*) a;
// std::string flag = "guessInput";
// while (1) {
// std::string msg = s->ReceiveLine();
// // 去除末尾的换行符
// msg = msg.substr(0, msg.size() - 1);
// // 以|分割得到要调用的方法名和具体参数
// int pos = msg.find_first_of('|');
// std::string func_name = msg.substr(0, pos);
// std::string func_arg = msg.substr(pos + 1);
// const char *result = "err";
// // 调用函数
// if(strcmp(func_name.c_str(), flag.c_str()) == 0){
// result = guessInput(func_arg.c_str());
// }
// else{
// result = getDeoaep(func_arg.c_str());
// }
// if (msg.empty()){
// break;
// }
// s->SendLine(result);
// }
// delete s;
// return 0;
// }

// int main(int argc,char **argv)
// {
// std::string::size_type sz;
// int port = std::stoi(argv[1], &sz);
// cout << "listen at:" << port << endl;
// SocketServer in(port, 10);
// while (1) {
// Socket* s=in.Accept();
// unsigned ret;
// _beginthreadex(0,0,Answer,(void*) s,0,&ret);
// }
// return 0;
// }
Binary file modified main.exe
Binary file not shown.
11 changes: 11 additions & 0 deletions offline_config_kktv.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"enc_session_key": "06bc18cf21b31cb195c6d691405ca18e2a1fbfd10fa308d0a186699f1a2cdc767f051f58c41068fdaaf1c2aa2c8f4e258ec8647dbbcc592fcfea03c47ca0f0d5c258520fc7450c4fd526fcb97c022e16413b8ee34d28ec4287a442bb05acf7cf6b6f282ee301a445925d043828e5a06cf4b4cd945189c70164fa96883a645f0f82738352c2da27a7d647ad2849483d62a913066c5fc5c81a0b0c5dba6f4c4f3b2893b75007ba0cccb7b1bdb8cc7df7b7b8b9907fa7c6f09a33ce885a40df046debae9d8152529da2f4e393ac2b6b55da26ffc3e4d5128f57d7363d4f156dec70d74fe2df6885f0fbb2c39f4f08be49a7571b43010da1dd323b516ab1f77211d8",
"enc_key": "01454e4352595054494f4e0012380a360a2008011210c6e3832808bd56b63738e89cdd0e35a31a046b6b747622046b6b747610011a1042fa073666acdd5f61dd4472809a1097180120fdd3928806301538bad598ff0942f01e0a146c6963656e73652e7769646576696e652e636f6d12101705b917cc1204868b06333a2f772a8c1ab01cfe3ada21f5e60b77bc09d278ffb9c4c4a3a459811dec57c4939c1a203a039b6cb4a98bcd99016eab315e215f09ffd1ca6be4fc95a5b3db6b20651c4da90427fbb028fb225b174b89d1d53a88b1278b43b17c560a8d1f69beccd0411f4e23f0ede6b87a4fe35454211a7ec7ed28076a1e958edea98d0d15cb3cae27c0758f3045a33a9df266dca35aa5b732532634633d66fd3460a9c498cb6e5ed9624992f52b22c5ad84acf777c8444e9291403d64339d022d44be2898ffcbd327036ac8cc2d602a8bf3a1b89b506fdd878063f29f938166b6aee690fa1e2a3e663060b773922c0b648ad0487e7885a44120f6bbfaaccde8a2a4a7b22805684d66053d6b11c345fe8cfb2c594a9a9ab0ca2ae8abf27602af92819d09be8d565d62012f95cfc01525ea52a4a190523f38782a47fd9708a46fa5354e26de8e81daeba05222b48da9254566d3fedcccce8ed440f8017adf44f388825744f9b88f4410ed33b1106df63c883a2ec9b824dbad27c4099bc0683d0a3a65885dca57ffc04c2f68dde61357a4cc40ff8b75152ccfc85f6389a830d5ba34ccaddd6a1dc8b6fa8b4217fcec58b5d47150a492d91a7aff0146b2ccaa154a8e0b49cb493509f4189d74d40728693a9ee0e1bca0b0d88e602883bce1e06187257e57d85c3e0d7def3a90658ab5613f806e019ef122f30c340f41c8f03e358414a76231815375b3fcb36a3cb2b0d8522081e6c0a078a937ee1fdc4d27de835043629d80678a73dae255e23b94e977c6f467484e745b02214bb0e8f965f05086e33a25e3ae1dc120fd33e92166d0189db7f5d42aeb9665caebdde2f7f8bd6eeaa4cc07eac11ef2f0eacc5a82511813d9f457e8b70082f87e5030cd35c51d7574e43555e63837f28ea17c52fa5d6cdc68fe6d1f5b093997f47b9530205e9396e4ad0078abb7470de1b607fccd9efb033b4a56f348288b9cb757b07a0269700d9a4650f76e82a3780b6ee1d74e1f037c9b9b929ea53cf69291e1bd5d974b4f5dc24a2cacead9f7b95de0962ff887136fd957bfb32b184fdf8996fef9d0dba3f461db8bdbc6a900cae1a403cfbc7f66b974b21371004ca28084daeff9b8c287aded25776bf35fd78fdd35911457f8e7ab25d1e431348174e9c01a6583390d8ef8494f82aad27e5b5be3cb121aa54cb2cd3dd17ff46b2234bf18241f978ed381e1490de49a06e9488b324da3695f20b47c3c6185fae9968102c0c111160ab8b9ae3981a5fcc30a47b844a295bd83fc1c515f679022c9bfd0d6dd7e1f342532c7fb697be9348fffeb0ba2aec9421077bd8cd220c5d827933c0fdc7928f87f70a9eba894e9328336ad36d6e9aa0e49e70ebf39dc8a154554c5bdf5f645621dbf1462a84f431b46058e1fce2928f97b7a4ca08bf2ce7e8b9334f305026191067a48fb1161798bb9c26ffa6e3dcf2baf8a89f66714ab6594df005daa7c571942a94dd012182c3429f9db663b69944e5e5d33564bd9be5b659d255b6352e6530663c4c4c0627b3e76773b400733b7cd74f0c5c962411423df9ffaaf45a29b06590f06bd1a8853f0cf2dea04addc45de5d56cff31c6bfa6f3ddf0c0c09ee4cfb92849d7da65618d5b459ff3507a9935ce38806412c7411275e7b6867c9876ed1130786e67f1d47029a71a4a1aecb1ab38499e9cb053c3eeb9996cf262c6d71d2c5993dcc2fde2a3f1a5590e356be0587320f7cd16eb0fe0b174a368ceb21c0b4fcfa25e5ed94cad1bdebb4ee03fbdab8c7d9daff558d27312e7f1b5d4c8a349737cf51920563703ec46028d2b84991d9406401ecb8f5ca3b490d3853bc8bbe80f5bfd50e7b4707d22b57958c766a28c3646b13306429a07a09f0d48aacf1c0fcb3dc8a805da1e7527cc73f2449309e2127c0e22df7c8cd9183f2c4f1b1298c6bdd5bf69c45152d0731d37127bb6346ea197d69ed67d6a7371926b1317fc335cf33bc2cff960c54830d108a669eb7e2357c8b0a7726f9cbef689b72ca64874bde7a4c42b10aa8dd2302d6d1ef4a8924c887b2451bbe5ef847d189c77fd2d98070d317853dd660fe54ce60b474d12f9a724c4948a73062e59e1396a893b5ae6bbeac7827735efa59daf10895aa1a57ae19ee60a01a0b3a611abe993bac22856520b88c73d15dfad33ee02a16158a06cbf9fd4da485a7bb32da2fc4f63183568e99df683d150babdb5cdcbbdae5a1ddfcca57a118e3a748810b39852019d69b46602d2dba60f09754ba902ca4648884b90ea3ee1ab3d16a37778fc79ce94cf0d0006b41b793ec88e6fa5fdf0ea51f246368f2b7b35fad85ec4dc18bbaa11a65cf4529d24a121e632ad9c88facb343588f645619f0742fcad03db8c282cacc5640c521e6e3c112fb9aefe5163a0bfdfdd511288bbc62d1cee31791f9c4c8e6bfd387ae4bcb2c468281bd38c98e2312fd8ab6f47ecf22b29adf474f2de4050745b0f89a6453e18ad0902bdc32dd4fe63a76efbd04f0e93df26bf1b48003a35d6db8d93d657720e5bba091b39846d926eee1dcc66bd07cbde3857902567c98da61a92be1d683c4f2055b90bb5da1bad9b5dd8d7d3266d04c7dc59d610a77a5563f1778a94e71eeb6f028a4ea38db8ceb62917c2b17786b98b9f86cbc029ed36b91b098cdf16ad28dc13efc2e1a055b8a8453cab4e566503d4e95cdafe9707820f51bc87913a3dbcd5d1eab3e359210026b08be78b75880dd5761b88aa6118f2a0cab6af5405f3999eb5ab676f5c9aadd404e8f37a6a1e872d6c2b282657d8c253b9a78f2758477db1f8b38c0ade07e10bca3c975e01983ab4d80e648c37bd104124cd3324ae529f6d9861236f8f63b36601aabc4b35138a73f3922fcf367f376cf52d970d2d52755b55bde11785b21a03b0c67f0a25d25662bf4232def6eeb613586c7602ea73a0401a16da22b5b8178eb92bc86c40c0500b2d79092ae9ca01f7788c274caf543ac17a955c7b86533a3250036503b27ce1aa27b7a929fc90d5f0fd50671a7ea321096e436cac3d49ada63be57babbe6b92cf2f456a463427e002fe56fc8f04baacecf7a789f81fdc1a3dec0a55cf80feee6c4b1ea0e4617eb0926207ec6495eecac68d33866ebb23576dbe72ca3908b0e30b1f0d7675bc279cefe42d767b84571f4b7ca485b7825d6c131468abd2497396474dcdbb53594f79c0b434e229da8557e5d63bd736f4df4f6c21f203e9746f907931251648c5753e16f91d0578587cb7c73432df314f2a75877b576b479101c28a56db82c81e3ca1fc923cf45c65ddfdb0fe308f2bbc5067393806730d80c52a355b7521736808fdad55b32cfcf569517084ddf1ef7c74d3eb684e564813a1caf03cd72d3c22326a41422a63543b7b2d74828208a2bc2e9ac788c467b127f8e8218c46e23a18160750ff08bf6180c8c734912d12848d462e894c5853d6646abbb5be3d86bed2a23edb756cc1b71eab0b21bec22b1e366d278b72533515247ea019742310cd7cab299bb9548ef8014d4cfe33dcb5ac882f174df82b8f6b357a529e01f5ec0bf101eb10d5d2525bddc73115a3bcd9d5a13c41d4c0dc30551486b029154ae7ade8a83a24a42ed0934d033ba5c6b8ddaffafcf7912ce3dfdc319b4e7b882ea64da386fb893ecb6ed86facad532bbc23c16edc8413a8ccf4b3709e450c309880092f1a1db22b41cf2c8736e66aeb42aa0ccc93392c541a677808cf4c2bcc66f3754f5d41d204e448dde7e32932ea1169ee97941494ca1a66ee05a4f0a1bb45f6e093a1fb2036e2bcb7ec4d00b6a97a5377cd2b372f8e1f4db218447a05cf0fcbbda6cf0e7f3d890b37b0af872fdc4a1f735a0b7d77606d041f0c1effa9a7c68f9c266df9fa6916de5d0fe7dcf9f2f36eb1bf1503063fcb2e1defddb1a62d0b27e88d37199ddb29a9f57bc4452e319fd5182a66433899b0a09e7ddcbc007e7ebf01f90e6466f772f7c521d75adfa8c4954e95f4009deeaff70806c06e8390928ab1ab7fcf2813f52e217f3df010a9d685d924ced8c708415d0bbb1e809dae527fd4673f0dc6349cb598b1b6676b26cc88da81a3e751023b29eddb36f39b8b552ed46487e5bdc87236a6c002fcc48c59742077083e91edc1fe449b6755a323ae89f853494e20fd56457f175af4d44f96e249e66549bf1411ee844cba22d69c9fad138ad2abbb2bd9935776c977e017c569f2f0aea759cf2b8988cbb987680376e13dd59e2a43ea796ebca145bb1b20d6ada1a1302c6d8d4f7816fbb8191b7111bed874f4cd391692aaea5a9ac67873a8b48fe99941f2cad0f20efd8514aeda371d1920f53ec3dd2cfce30f1db4cee445936ef7ff42659bb298341c4cf0f8e6a6e1dbedfb721a628218b69171cc48ba13b2826d03e70e2f7c8707bea5d3339d760072f6cd735339ca46eeb0cfdc4af5ad49ddb466f0be4a4adc60e0178b4c1543705a1d092375d56540adf1ddb7e9d2a9e03796867bfe76b358ffce505082c19ef9db200f487d500513cad1a8c272573bab12139672602213d616f0204ee65d4b7f95cf13e1ae9d0114f7b143707aabc43d147117b9de131f9c410ec229c092df074b1376edc07e9c9e09718ef44a86ad5ac001bfe89cd980a2c68355e2008a0ba37af46e7a361318cf91636242f7b37a0f42d3345da824f50c3a37a0d5d49d6c72a21fd5737c45896c0ef8d6dad4f49bfa54a6e06c2be4ce2e8337e5831c447dadf303dce89160fd2048e8fb0d14fddd1a66e4563c81a803b79c3095944b451eb91ed802a75aabc35e9419edcf4eb2e7b312ec0413039b81dae459b52607ac3988393663fcdcd64df64cc00a36ea36b9baa21189669bc779a7392cacd51fcc9c48c5b3e42c4f1bdae0934f80a9a8c575487246030cf9d27e016697b315200e19912ddf68bedcb5e24d3d9d4da337cb0a4dedfbb8e8da79ad01a655c6b4756bcea04bee874f5fcc2e18eeabe2f1009bdbdb488e5bb631082f6704efb5d63f7473799d24d62c404edcfd6ef37e7f842363b76b0019d3e2e2efe90f66149aa52b7097b2f063ce31714e5e82cf7a9786b86cfc7df41307dc24793103bd67bcc910a71de9f1054fa82012f262c32c84de04cbc952c82880edcf3d217e88200a657906f6cb0ace2d0031a5594b041221006ae6206795ed824d1c90534bb90f9c62a80028cb5cf39aaf015b60396fe1d9b206d699177d8ee2bcc8221f3384a5fd04544f455856394d0bd15f35bf0da3b850a03a72313aa326068bbf78520e88599f8047f820eb157e2d81554f080def1528d9f13d73846ba2ac08940bc80182a69a451eadae623c3cb92965a86f7d02259872a9bbfc0db281d9a4c7c578c6239df21e724513e05806835f3f9f7904586b4afa777a0264636cfd475b546430e748497a6b6eab4b70f8b94fc90118e9cbc4957a67b6920552b855a56b21afa8b3adf362733fae7eb84eb5a0eb848eca0c090da0163e6a411b96296610867cc9590f650c53dfc730a1553a79453cc5dfd4cc2687a38dd072e59056a1be3e93dd33d695d88f900000080",
"key_infos": {
"0": [
"c6e3832808bd56b63738e89cdd0e35a3",
"4c66d6685a9d66270a8b5d56f2158387",
"cf37f2998d78cd3f078f2fd2e328c9a9"
]
}
}
Loading

0 comments on commit e643b4f

Please sign in to comment.