-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSource1.cpp
95 lines (71 loc) · 1.8 KB
/
Source1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include<sstream>
#include<string>
#include<cstring>
#include<iostream>
#include<sys/socket.h> //socket
#include<arpa/inet.h> //inet_addr
#include <unistd.h>
#include <netdb.h>
#include <openssl/bio.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
struct triggerblock
{
double q;
long long block[3];
long long b;
long long t;
// tm *c;
// tm *p;
unsigned char ptrigger;
float outofthis;
double x;
long double F;
short finishup;
double f;
unsigned char E;
};
int main(int argc , char *argv[])
{
triggerblock mo={};
int sock;
struct sockaddr_in server;
char server_reply[5000];
struct hostent *host;
//Create socket
sock = socket(AF_INET , SOCK_STREAM , 0);
host = gethostbyname("www.coingecko.com");
server.sin_addr.s_addr=*((unsigned long*)host->h_addr);
server.sin_family = AF_INET;
server.sin_port = htons( 443 );
connect(sock , (struct sockaddr *)&server , sizeof(server));
SSL_CTX *ctx = NULL;
OpenSSL_add_all_algorithms();
SSL_load_error_strings();
OPENSSL_init_ssl(0, NULL);
SSL_CTX *sslctx = SSL_CTX_new( SSLv23_client_method());
SSL *cSSL = SSL_new(sslctx);
SSL_set_fd(cSSL, sock);
//SSL_set_cipher_list(cSSL, "aNULL");
SSL_connect(cSSL);
char message[]="GET /en/price_charts/monero/usd HTTP/2.0\r\nhost:www.coingecko.com\r\n\r\n";
SSL_write(cSSL, message,strlen(message));
static int q;
std::string c;
std::stringstream fr;
do
{
mo.t=SSL_read(cSSL,server_reply ,4400 );
fr.write(server_reply,mo.t);
}
while(q++ < 54);
mo.b=fr.str().find("coin-value");
mo.b=fr.str().find("$",mo.b)+1;
fr.seekg(mo.b);
fr >> mo.F;
std::cout << mo.F<<'\n';
SSL_shutdown(cSSL);
SSL_free(cSSL);
close(sock);
return 0;
}