getflag.pl
Copying Source is Forbidden
90 lines of code
1
#!/usr/local/bin/perl
2
3
($<,$>) = (getpwnam('nobody'), getpwnam('nobody')) or die $!;
4
5
binmode(STDIN, ":utf8");
6
binmode(STDOUT, ":utf8");
7
8
# must have's!
9
use strict;
10
use warnings;
11
use CGI::Carp qw(fatalsToBrowser);
12
use DBI;
13
use URI::Escape;
14
15
use lib "/var/www/html/Pm";
16
17
use Html qw(pre_html_header header html_end debug_banner);
18
use Bc_chef qw(cookie_get);
19
use Bc_misc qw(get_param referrer get_params_asHash);
20
use Bc_sql qw(sql_execute
21
get_constant
22
get_flag_data
23
user_exists
24
$QUERY_PAGE
25
$QUERY_UID
26
$LOGGEDIN
27
28
$DB
29
);
30
use Redir qw(notice_redir error_redir);
31
use User qw(isUserModerator $USER_DATA);
32
use Security qw(banned);
33
34
my $DEBUG = 0;
35
36
my %params = get_params_asHash();
37
38
my $output = pre_html_header({type=>"text/plain"});
39
40
if (not user_exists($LOGGEDIN) or banned($LOGGEDIN) or not isUserModerator($LOGGEDIN)) {
41
my $msg = "Access Denied";
42
if ($DEBUG) { $msg .= " (getflag.pl)"; }
43
$output = error_redir("/", $msg);
44
} else {
45
############################################################
46
my $debug_str = "";
47
### YOUR CONTENT HERE
48
49
if ($DEBUG) {
50
$output = pre_html_header();
51
$output .= header(
52
"Get Flag",
53
"?nobg_img=1&nogrid=1",
54
0,
55
"setTimeout(removeMsg, " . get_constant("REMOVE_MSG_TIMEOUT") . ");",
56
"",
57
"style=\"padding: 2px;\""
58
);
59
$debug_str .= "fid = <b>$params{id}</b><br>\n";
60
}
61
62
my $rv = "";
63
my $flag = get_flag_data($params{id});
64
if ($flag) {
65
foreach my $key (keys %$flag) {
66
if ($key ne "link") {
67
$flag->{$key} =~ s/\=/=/g;
68
$rv .= "$key,$flag->{$key}|";
69
$debug_str .= "$key = <b>$flag->{$key}</b><br>\n";
70
}
71
}
72
73
$rv =~ s/\|$//;
74
$debug_str .= "<hr>\n";
75
$debug_str .= "return value = <b>$rv</b><br>\n";
76
}
77
78
if ($DEBUG) {
79
$output .= debug_banner("getflag.pl", $debug_str);
80
$output .= html_end();
81
} else {
82
$output .= $rv;
83
}
84
### END YOUR CONTENT
85
############################################################
86
}
87
88
print $output;
89
90
exit 1;