if($request["number"]) { if ($request["number"] != intval($request["number"])) { $msg = "Number must be integer!"; } elseif ($request["number"][0] === "+" || $request["number"][0] === "-") { $msg = "No symbol!"; } elseif (intval($request["number"]) != intval(strrev($request["number"]))) { $msg = "Do you know what is the palindrome number?"; } else { if(check($request["number"])) { $msg = "You did not pass the check! Sorry I can not give you the flag."; } else { $msg = "Here is your flag: ".$flag; } } }else{ header("hint: ?source"); die("Enjoy yourself!"); }
From: https://httpd.apache.org/docs/2.4/mod/prefork.html This Multi-Processing Module (MPM) implements a non-threaded, pre-forking web server. Each server process may answer incoming requests, and a parent process manages the size of the server pool. It is appropriate for sites that need to avoid threading for compatibility with non-thread-safe libraries. It is also the best MPM for isolating each request, so that a problem with a single request will not affect any other. This MPM is very self-regulating, so it is rarely necessary to adjust its configuration directives. Most important is that MaxRequestWorkers be big enough to handle as many simultaneous requests as you expect to receive, but small enough to assure that there is enough physical RAM for all processes.
import requests import socket import time from multiprocessing.dummy import Pool as ThreadPool try: requests.packages.urllib3.disable_warnings() except: pass
穷举有所 k 的长度(理论上从 1 到无穷,题目中告诉了从 1 到 50),在每一个 k 长度中对 k 的每一个字符进行穷举(从 0 到 255) k 中每个字符与 C 中对应字符进行异或,计算出明文 p,看 p 中多少字符在已知的明文字符集中,利用字频分析确定该穷举出的结果是否最优,穷举结束后取最优的一次穷举结果
From the hag and hungry goblin That into rags would rend ye The spirit that stands by the naked man In the Book of Moons defend ye That of your five sound senses You never be forsaken Nor wander from your selves with Tom Abroad to beg your bacon While I do sing Any food any feeding Feeding drink or clothing Come dame or maid be not afraid Poor Tom will injure nothing Of thirty bare years have I Twice twenty been enraged And of forty been three times fifteen In durance soundly caged On the lordly lofts of Bedlam With stubble soft and dainty Brave bracelets strong sweet whips ding dong With wholesome hunger plenty And now I sing Any food any feeding Feeding drink or clothing Come dame or maid be not afraid Poor Tom will injure nothing With a thought I took for Maudlin And a cruse of cockle pottage With a thing thus tall sky bless you all I befell into this dotage I slept not since the Conquest Till then I never waked Till the roguish boy of love where I lay Me found and stript me naked While I do sing Any food any feeding Feeding drink or clothing Come dame or maid be not afraid Poor Tom will injure nothing When I short have shorn my sows face And swigged my horny barrel In an oaken inn I pound my skin As a suit of gilt apparel The moons my constant mistress And the lovely owl my marrow The flaming drake and the night crow make Me music to my sorrow While I do sing Any food any feeding Feeding drink or clothing Come dame or maid be not afraid Poor Tom will injure nothing The palsy plagues my pulses When I prig your pigs or pullen Your culvers take or matchless make Your Chanticleer or Sullen When I want provant with Humphry I sup and when benighted I repose in Pauls with waking souls Yet never am affrighted But I do sing Any food any feeding Feeding drink or clothing Come dame or maid be not afraid Poor Tom will injure nothing I know more than Apollo For oft when he lies sleeping I see the stars at mortal wars In the wounded welkin weeping The moon embrace her shepherd And the Queen of Love her warrior While the first doth horn the star of morn And the next the heavenly Farrier While I do sing Any food any feeding Feeding drink or clothing Come dame or maid be not afraid Poor Tom will injure nothing The Gypsies Snap and Pedro Are none of Toms comradoes The punk I scorn and the cutpurse sworn And the roaring boys bravadoes The meek the white the gentle Me handle not nor spare not But those that cross Tom Rynosseross Do what the panther dare not Although I sing Any food any feeding Feeding drink or clothing Come dame or maid be not afraid Poor Tom will injure nothing With an host of furious fancies Whereof I am commander With a burning spear and a horse of air To the wilderness I wander By a knight of ghosts and shadows I summoned am to tourney Ten leagues beyond the wide worlds end Methinks it is no journey Yet I will sing Any food any feeding Feeding drink or clothing Come dame or maid be not afraid Poor Tom will injure nothing
//Set to be the smaller of the two decks. gameData.deckSize = gameData.ctfer.playerCards.deckSize > gameData.opponent.playerCards.deckSize ? gameData.opponent.playerCards.deckSize : gameData.ctfer.playerCards.deckSize;
printf("Welcome\n"); printf("Enter your name: \n"); memset(gameData.name,0,NAMEBUFFLEN); if(!readInput(gameData.name,NAMEBUFFLEN)){ printf("Read error. Exiting.\n"); exit(-1); } printf("Welcome %s\n", gameData.name); while(1){ size_t playerIndex = gameData.ctfer.playerCards.top; size_t oppIndex = gameData.opponent.playerCards.top; oppCard = &gameData.opponent.playerCards.cards[oppIndex]; playCard = &gameData.ctfer.playerCards.cards[playerIndex]; printf("You have %d coins.\n", gameData.playerMoney); printf("How much would you like to bet?\n"); memset(betStr,0,BETBUFFLEN); if(!readInput(betStr,BETBUFFLEN)){ printf("Read error. Exiting.\n"); exit(-1); }; bet = atoi(betStr); printf("you bet %d.\n",bet); if(!bet){ printf("Invalid bet\n"); continue; } if(bet < 0){ printf("No negative betting for you!\n"); continue; } if(bet > gameData.playerMoney){ printf("You don't have much.\n"); continue; } printf("The opponent has a %d of suit %d.\n", oppCard->value, oppCard->suit); printf("You have a %d of suit %d.\n", playCard->value, playCard->suit); if((playCard->value * 4 + playCard->suit) > (oppCard->value * 4 + playCard->suit)){ printf("Something must be wrong...\n"); if(checkInvalidCard(playCard)){ printf("That's not actually a valid card.\n"); }else{ printf("You won!\n"); gameData.playerMoney += bet; } }else{ printf("You lost!\n"); gameData.playerMoney -= bet; } gameData.ctfer.playerCards.top++; gameData.opponent.playerCards.top++; if(gameData.playerMoney <= 0){ printf("You are out of coins. Game over.\n"); exit(0); }elseif(gameData.playerMoney > 500){ printf("You won the game!\n"); system("/bin/sh -i"); exit(0); }
if(gameData.playerMoney <= 0){ printf("You are out of coins. Game over.\n"); exit(0); }elseif(gameData.playerMoney > 500){ printf("You won the game!\n"); system("/bin/sh -i"); exit(0); }
其余代码就不具体分析了,存在溢出的结构体为
1 2 3 4 5 6 7
typedefstruct _gameState{ int playerMoney; player ctfer; char name[NAMEBUFFLEN]; size_t deckSize; player opponent; } gameState;
宏中定义了 name 数组的大小 NAMEBUFFLEN 为 32,但是再看存储玩家输入的 name 的时候代码做了什么
很明显的可以看到 opponent 的牌 value 明显大于我们,那么我们在出牌的时候 value 就会是 opponent 的 value 了 注意 top 时同时增长的,我们的 top 到了 opponent 的数据区里,而 opponent 的 top 到哪就不关我们的事了,这样就能赢了 最后拿到 shell,flag 为