-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.php
More file actions
207 lines (165 loc) · 5.14 KB
/
index.php
File metadata and controls
207 lines (165 loc) · 5.14 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>BooTweet</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/foundation.min.css">
</head>
<body>
<?php
$boot = new BooTwitter();
$username = @htmlspecialchars($_POST['user']);
$password = @htmlspecialchars($_POST['password']);
$comment = @htmlspecialchars($_POST['comment']);
if ($_POST && $username && $password && $comment) {
// Ingresa los accesos
$boot->setUserName($username);
$boot->setPassword($password);
// Inicia boot
$boot->startBoot();
// Envia Mensaje
$boot->sendMessage($comment);
// Cierra conexion y session de boot
$boot->endBoot();
} else {
// Muestra formulario
echo $boot->showLoginForm();
}
?>
</body>
</html>
<?php
/**
* BooTweet
*
* By Camilo Galdos @SeguridadBlanca
* Modified by Esteban Rodriguez @Pnkkito
*/
class BooTwitter
{
private $_tweet = 'BooTweet Message by @SeguridadBlanca Modified by @Pnkkito';
private $_user = '';
private $_passwd = '';
private $_conn = null;
private $_url = '';
private $_token = '';
private $_user_agent = 'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; NOKIA; Lumia 800)';
private $_cookie = 'cookies.txt_file';
public function __construct(){
$this->_startConnection();
}
public function __destruct(){
$this->_tweet = 'BooTwitter Destroyed';
$this->_user = '';
$this->_passwd = '';
$this->_conn = null;
}
private function _startConnection(){
$this->_conn = curl_init();
}
private function _endConnection()
{
curl_close($this->_conn);
}
private function _sendRequest($post = null){
if ($this->_conn) {
curl_setopt($this->_conn, CURLOPT_URL, $this->_url);
if($post){
curl_setopt($this->_conn,CURLOPT_POSTFIELDS, $post);
curl_setopt($this->_conn, CURLOPT_POST, 1);
}
else{
curl_setopt($this->_conn, CURLOPT_POST, 0);
}
curl_setopt($this->_conn, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->_conn, CURLOPT_COOKIEJAR, $this->_cookie);
curl_setopt($this->_conn, CURLOPT_HEADER, 0);
curl_setopt($this->_conn, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($this->_conn, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($this->_conn, CURLOPT_USERAGENT, $this->_user_agent);
return curl_exec($this->_conn);
}
return null;
}
private function _getToken($html){
preg_match("/input name=\"authenticity_token\" type=\"hidden\" value=\"(.*?)\"/", $html, $authenticity_token);
return $authenticity_token[1];
}
private function _getAccess(){
//
$this->setUrl('https://mobile.twitter.com/session/new');
//
$html_request = $this->_sendRequest();
$this->_token = $this->_getToken($html_request);
}
private function _getLogin(){
//
$this->setUrl('https://mobile.twitter.com/session');
//
$html_request = $this->_sendRequest('authenticity_token='.$this->_token.'&username='.$this->_user.'&password='.$this->_passwd);
}
public function sendMessage($message = null){
//
$this->setUrl('https://mobile.twitter.com/');
if ($message) {
$this->_tweet = $message;
}
//
$html_request = $this->_sendRequest('authenticity_token='.$this->_token.'&tweet[text]='.$this->_tweet.'&commit=Tweet');
}
private function _closeLogin(){
//
$this->setUrl('https://mobile.twitter.com/session/destroy');
//
$html_request = $this->_sendRequest('authenticity_token='.$this->_token.'&commit=Sign out');
}
// SETTERS
public function setUserName($username){
$this->_user = $username;
}
public function setPassword($password){
$this->_passwd = $password;
}
public function setMessage($message){
$this->_tweet = $message;
}
public function setUrl($url){
$this->_url = $url;
}
public function setUserAgent($user_agent){
$this->_user_agent = $user_agent;
}
public function startBoot(){
$this->_getAccess();
$this->_getLogin();
}
public function endBoot(){
$this->_closeLogin();
$this->_endConnection();
}
public function showLoginForm(){
$form = '';
$form .= '<div class="row">';
$form .= '<div class="large-5 large-centered columns"> ';
$form .= '<form action="" method="post">';
$form .= '<fieldset>';
$form .= '<legend>Login</legend> ';
$form .= '<label>Username';
$form .= '<input type="text" name="user" id="" placeholder="Username" required>';
$form .= '</label>';
$form .= '<label>Password';
$form .= '<input type="password" name="password" id="" placeholder="******" required>';
$form .= '</label>';
$form .= '<label>Tweet';
$form .= '<input type="text" name="comment" id="" placeholder="Tweet Message" required>';
$form .= '</label>';
$form .= '<button type="submit" class="button right">Login</button>';
$form .= '</fieldset>';
$form .= '</form>';
$form .= '</div>';
$form .= '</div>';
return $form;
}
// GETTERS
}