Permalink
Browse files

Some shit

  • Loading branch information...
LTommy committed Dec 7, 2017
1 parent 1fc39e4 commit 8c3c543db4d510bc2ba4bced194a03d2c0f970b0
View

This file was deleted.

Oops, something went wrong.
File renamed without changes.
View
Binary file not shown.
No changes.
View

This file was deleted.

Oops, something went wrong.
View
@@ -0,0 +1,24 @@
#include "experiment.h"
#include "redis.h"
#include <iostream>
#include <string>
#include <vector>
using namespace std;
Experiment::Experiment(string exp_kind, int id, Redis &redis){
this->exp_kind = exp_kind;
this->exp_id = exp_id;
}
int Experiment::update_all(Redis &redis)
{
// this->exp_all_count = redis.hget("");
}
int main()
{
Redis redis;
cout << redis.hget("test:008", "name");
Experiment pwn1("pwn", 0, redis);
pwn1.update_all(redis);
}
View
@@ -0,0 +1,25 @@
#ifndef EXPERIMENT_H
#define EXPERIMENT_H
#include "redis.h"
class Experiment
{
public:
Experiment(std::string exp_kind, int exp_id, Redis &redis);
std::string exp_name;
int exp_id;
int exp_score;
std::string detail;
std::string hints;
int top3[3];
int update_all(Redis &redis);
int exp_all_count;
std::string exp_kind;
private:
std::string exploit_sample;
std::string flag;
};
#endif //EXPERIMENT_H
View
Binary file not shown.
View
@@ -0,0 +1,10 @@
#include "experiment.h"
#include "redis.h"
#include <iostream>
using namespace std;
int main(){
Redis redis;
Experiment pwn1;
pwn1.update_all(redis);
}
View
@@ -24,16 +24,52 @@ Redis::Redis(const char *ip = "59.110.229.246", int port = 6379, const char *pas
redisReply *reply = (redisReply *)redisCommand(this->context, "auth %s", password);
}
string Redis::hget(const char *key, const char *hkey)
Redis::Redis()
{
const char *ip = "59.110.229.246";
int port = 6379;
const char *password = "toor";
this->context = redisConnect(ip, port);
if (this->context == NULL || context->err)
{
if (context)
{
printf("Error: %s\n", context->errstr);
exit(-1);
}
else
{
printf("can not allocate redis context\n");
exit(-1);
}
}
redisReply *reply = (redisReply *)redisCommand(this->context, "auth %s", password);
}
int Redis::hmset(string key, vector<string> &hkeymap)
{
string hkeys("");
//string value;
int i = 0;
for (auto it = hkeymap.cbegin(); it != hkeymap.cend(); it++){
if (i % 2 != 0)
this->hset(key, (*(it-1)).c_str(), (*it).c_str());
i++;
}
return 1;
}
string Redis::hget(string key, string hkey)
{
const char *argv[3];
size_t argvlen[3];
argv[0] = "HGET";
argvlen[0] = 4;
argv[1] = key;
argvlen[1] = strlen(key);
argv[2] = hkey;
argvlen[2] = strlen(hkey);
argv[1] = key.c_str();
argvlen[1] = strlen(key.c_str());
argv[2] = hkey.c_str();
argvlen[2] = strlen(hkey.c_str());
redisReply *reply = (redisReply *)redisCommandArgv(this->context, 3, argv, argvlen);
string value;
if (reply->type != REDIS_REPLY_NIL)
@@ -44,17 +80,17 @@ string Redis::hget(const char *key, const char *hkey)
return value;
}
int Redis::hset(const char *key, const char *hkey, const char *value)
int Redis::hset(string key, string hkey, string value)
{
redisReply *reply = (redisReply *)redisCommand(this->context, "HSET %s %s %s", key, hkey, value);
redisReply *reply = (redisReply *)redisCommand(this->context, "HSET %s %s %s", key.c_str(), hkey.c_str(), value.c_str());
freeReplyObject(reply);
return 1;
}
int Redis::del_key(const char *key)
int Redis::del_key(string key)
{
int res = 0;
redisReply *reply = (redisReply *)redisCommand(this->context, "DEL %s", key);
redisReply *reply = (redisReply *)redisCommand(this->context, "DEL %s", key.c_str());
if (reply->type == REDIS_REPLY_INTEGER)
{
if (reply->integer == 1L)
@@ -64,9 +100,9 @@ int Redis::del_key(const char *key)
return res;
}
int Redis::existsKey(const char *key)
int Redis::existsKey(string key) //exist:1 no:0
{
redisReply *reply = (redisReply *)redisCommand(this->context, "exists %s", key);
redisReply *reply = (redisReply *)redisCommand(this->context, "exists %s", key.c_str());
int res = 0;
if (reply->type == REDIS_REPLY_INTEGER)
{
@@ -127,7 +163,14 @@ Redis::~Redis()
redisFree(this->context);
}
int main(){
/*int main(){
Redis redis;
cout << redis.hget("test:001", "name");
}
vector<string> temp;
temp.push_back("name");
temp.push_back("test:007");
temp.push_back("pass");
temp.push_back("test:007");
redis.hmset("test:007", temp);
cout <<redis.existsKey("test:0107");
}
*/
View
@@ -9,11 +9,12 @@ class Redis{
public:
redisContext* context;
Redis(const char *ip, int port, const char *password);
std::string hget(const char *key, const char *hkey);
int hset(const char *key, const char *hkey, const char* value);
int hmset(const char *key, std::vector<std::string> hkeymap);
int del_key(const char *key);
int existsKey(const char *key);
Redis();
std::string hget(std::string key, std::string hkey);
int hset(std::string key, std::string hkey, std::string value);
int hmset(std::string key, std::vector<std::string> &hkeymap);
int del_key(std::string key);
int existsKey(std::string key);
int wrapping_and_init();
virtual ~Redis();
View
Binary file not shown.
View
Binary file not shown.
View
@@ -0,0 +1,16 @@
#include "user_panel.h"
#include "redis.h"
#include <iostream>
#include <vector>
using namespace std;
User::User(const char*username){
}
int User::list_all_exp(Redis redis){
}
int main(){
User user;
}
View
@@ -0,0 +1,22 @@
#ifndef USER_PANEL_H
#define USER_PANEL_H
#include "../include/server.h"
class User{
public:
User(const char*username);
int list_all_exp(Redis redis);
void show_score();
private:
const char *sessionId;
const char *username;
};
class Admin:User{
public:
int new_exp();
int new_user();
};
#endif //USER_PANEL_H
View
Binary file not shown.

0 comments on commit 8c3c543

Please sign in to comment.