forked from koto/xsschef
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathserver.php
58 lines (50 loc) · 1.89 KB
/
server.php
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
<?php
/*
XSS ChEF - Chrome Extension Exploitation framework
Copyright (C) 2012 Krzysztof Kotowicz - http://blog.kotowicz.net
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
header('Access-Control-Allow-Origin: *');
ini_set('session.use_cookies', false);
session_id('dummy'); // use PHP sessions for persistent storage
session_start();
function nocmds($v) {
return strpos($v, '-cmd') === false;
}
if (!empty($_GET['delete'])) { // fix memory errors
$_SESSION = array();
die();
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_GET['ch'])) {
// push to channel
if (empty($_SESSION[$_GET['ch']])) {
$_SESSION[$_GET['ch']] = array();
}
$p = file_get_contents('php://input');
$_SESSION[$_GET['ch']][] = json_decode($p);
echo json_encode(count($_SESSION[$_GET['ch']]));
} else if (!empty($_GET['ch'])) {
// pull from channel
if (empty($_SESSION[$_GET['ch']])) {
echo json_encode(array());
} else {
echo json_encode($_SESSION[$_GET['ch']]);
unset($_SESSION[$_GET['ch']]);
}
} else { // echo available not-empty channels
$list = array();
// get channel list
foreach (array_filter(array_keys($_SESSION), 'nocmds') as $channel) {
$list[] = array('ch' => $channel);
}
echo json_encode($list);
}