forked from shack2/SNETCracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrackPostgreSQL.cs
More file actions
52 lines (48 loc) · 1.43 KB
/
CrackPostgreSQL.cs
File metadata and controls
52 lines (48 loc) · 1.43 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
using Npgsql;
using System;
using System.Data;
using Tools;
namespace SNETCracker.Model
{
class CrackPostgreSQL : CrackService
{
public CrackPostgreSQL()
{
}
public override Server creack(String ip, int port, String username, String password, int timeOut)
{
NpgsqlConnection conn = null;
Server server = new Server();
try
{
NpgsqlConnectionStringBuilder sb = new NpgsqlConnectionStringBuilder();
conn = new NpgsqlConnection("Server=" + ip + ";Port=" + port + ";User Id=" + username + ";Password=" + password + ";Database=postgres;Timeout=" + timeOut + ";ConnectionLifeTime = " + timeOut);
conn.Open();
server.isSuccess = ConnectionState.Open.Equals(conn.State);
if (server.isSuccess)
{
server.banner = conn.ServerVersion;
}
}
catch (Exception e)
{
if (e.Message.IndexOf("28000") != -1)
{
throw new IPBreakException(ip + port);
}
else
{
throw e;
}
}
finally
{
if (conn != null)
{
conn.Close();
}
}
return server;
}
}
}