-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnection_Test.php
More file actions
executable file
·135 lines (130 loc) · 4.96 KB
/
Copy pathConnection_Test.php
File metadata and controls
executable file
·135 lines (130 loc) · 4.96 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
<?php
### This is the master script that will run all of the connection tests and pass the results to the logger
# Vars
$dir = '/srv/http/utils'
$phpbin = '/uisr/bin/php'
if(is_null($argv[3]))
{
echo "Usage: $argv[0] Tests('p'=Ping,'t Username Password Command'=Telnet,'F Username Password'=FTP,'P #'=Port Number) Asset Server\n";
return;
}else{
//echo "Port_Arg = ".$Port_Arg."\n";
$Connection_Type = $argv[1];
echo "Connection_Type = ".$Connection_Type."\n";
# Ping Test
if (strstr($Connection_Type,"p"))
{
$Server = $argv[3];
$Asset = $argv[2];
$Date = date("Y-m-d-H-i");
//echo "Ping Called\n";
$Ping_CMD = "$phpbin $dir/Ping_Test.php ".$Server." 5";
//echo "Ping_CMD = ".$Ping_CMD."\n";
$Ping_Result = shell_exec($Ping_CMD);
if(strstr($Ping_Result,'Success'))
{
echo "Ping Success. Logging\n";
$Ping_Log = "$phpbin $dir/Log_Connection.php '".$Asset."' 0 0 '".$Date."' '".$Server."'";
echo "Ping_Log = ".$Ping_Log."\n";
$Ping_Log_Results = shell_exec($Ping_Log);
}else{
echo "Ping Failure. Logging\n";
$Ping_Log = "$phpbin $dir/Log_Connection.php '".$Asset."' 0 1 '".$Date."' '".$Server."'";
echo "Ping_Log = ".$Ping_Log."\n";
$Ping_Log_Results = shell_exec($Ping_Log);
}
}
# Port Test
$Date = date("Y-m-d-H-i");
if (strstr($Connection_Type,"P"))
{
if(is_numeric($argv[2]))
{
$Port = $argv[2];
$Server = $argv[4];
$Asset = $argv[3];
$Port_Result = '';
}else{
echo "Usage: $argv[0] P Port-Number Asset Server\n";
return;
}
#echo "Port Test Called\n";
$Port_CMD = "$phpbin $dir/Port_Test.php '".$Server."' ".$Port;
#echo "Port_CMD = ".$Port_CMD."\n";
$Port_Result = shell_exec($Port_CMD);
#echo "Port_Result = ".$Port_Result."\n";
if (strstr($Port_Result,'Port '.$Port.' open'))
{
#echo "Port open. Logging\n";
$Port_Log = "$phpbin $dir/Log_Connection.php '".$Asset."' 1 0 '".$Date."' '".$Server."'";
#echo "Port_Log = ".$Port_Log."\n";
$Port_Log_Results = shell_exec($Port_Log);
}else
{
#echo "Port closed. Logging\n";
$Port_Log = "$phpbin $dir/Log_Connection.php '".$Asset."' 1 1 '".$Date."' '".$Server."'";
#echo "Port_Log = ".$Port_Log."\n";
$Port_Log_Results = shell_exec($Port_Log);
}
}
# Telnet Test
if (strstr($Connection_Type,"t"))
{
$Date = date("Y-m-d-H-i");
echo "Telnet Test Called\n";
if(is_null($argv[6]))
{
echo "Usage: $argv[0] t Username Password Command Asset Server\n";
return;
}else{
$Username = $argv[2];
$Password = $argv[3];
$Command = $argv[4];
$Asset = $argv[5];
$Server = $argv[6];
}
$Telnet_CMD = "$phpbin $dir/Telnet_Test.php '".$Server."' '".$Username."' '".$Password."' '".$Command."'";
echo "Telnet_CMD = ".$Telnet_CMD."\n";
$Telnet_Result = shell_exec($Telnet_CMD);
if(strstr($Telnet_Result,$Username."@"))
{
$Telnet_Log = "$phpbin $dir/Log_Connection.php '".$Asset."' 2 0 '".$Date."' '".$Server."'";
$Telnet_Log_Results = shell_exec($Telnet_Log);
}else
{
$Telnet_Log = "$phpbin $dir/Log_Connection.php '".$Asset."' 2 1 '".$Date."' '".$Server."'";
$Telnet_Log_Results = shell_exec($Telnet_Log);
}
}
# FTP Test
if (strstr($Connection_Type,"F"))
{
echo "FTP Test Called\n";
if (is_null($argv[5]))
{
echo "Usage: $argv[0] F Username Password Asset Server\n";
return;
}else{
$Username = $argv[2];
$Password = $argv[3];
$Asset = $argv[4];
$Server = $argv[5];
$FTP_CMD = "$phpbin $dir/FTP_Test.php '".$Server."' '".$Username."' '".$Password."'";
echo "FTP_CMD = ".$FTP_CMD."\n";
$FTP_Result = shell_exec($FTP_CMD);
if (strstr($FTP_Result,'Success'))
{
echo "FTP Success. Logging\n";
$FTP_Log = "$phpbin $dir/Log_Connection.php '".$Asset."' 3 0 '".$Date."' '".$Server."'";
echo "FTP_Log = ".$FTP_Log."\n";
$FTP_Log_Results = shell_exec($FTP_Log);
}else{
echo "FTP Failure. Logging\n";
$FTP_Log = "$phpbin $dir/Log_Connection.php '".$Asset."' 3 1 '".$Date."' '".$Server."'";
echo "FTP_Log = ".$FTP_Log."\n";
$FTP_Log_Results = shell_exec($FTP_Log);
}
}
}
}
?>