SeaWolf-AI commited on
Commit
b326ed7
Β·
verified Β·
1 Parent(s): 12bea74

Local checker v2 file name

Browse files
Files changed (3) hide show
  1. index.html +6 -6
  2. local/keyguard-local.ps1 +42 -12
  3. local/keyguard-local.py +71 -13
index.html CHANGED
@@ -298,12 +298,12 @@
298
  <div class="card checker addrguide" id="guide" style="margin-top:18px">
299
  <h2 data-i18n="lc_lh"></h2>
300
  <p>1. <span data-i18n="lc_l1"></span></p>
301
- <div class="row"><a class="secbtn dl" href="local/keyguard-local.ps1" download="keyguard-local.ps1" data-i18n="lc_lw"></a><a class="sl" href="https://huggingface.co/spaces/FINAL-Bench/KeyGuard/blob/main/local/keyguard-local.ps1" target="_blank" rel="noopener" data-i18n="lc_src"></a></div>
302
- <div class="gl"><span data-i18n="lc_run"></span> Β· PowerShell</div><textarea id="runwin" class="cmd" readonly rows="2">powershell -ExecutionPolicy Bypass -File "$HOME\Downloads\keyguard-local.ps1"</textarea><button class="secbtn cp" data-for="runwin" data-i18n="gd_copy"></button>
303
- <div class="gl hs">SHA-256 59a32327a9691de1c947f8c232cad003cb78d86d7e686b598639c575bbdaf9bc</div>
304
- <div class="row"><a class="secbtn dl" href="local/keyguard-local.py" download="keyguard-local.py" data-i18n="lc_lp"></a><a class="sl" href="https://huggingface.co/spaces/FINAL-Bench/KeyGuard/blob/main/local/keyguard-local.py" target="_blank" rel="noopener" data-i18n="lc_src"></a></div>
305
- <div class="gl"><span data-i18n="lc_run"></span> Β· Terminal</div><textarea id="runnix" class="cmd" readonly rows="2">python3 ~/Downloads/keyguard-local.py</textarea><button class="secbtn cp" data-for="runnix" data-i18n="gd_copy"></button>
306
- <div class="gl hs">SHA-256 8d0d0f40702b230eb2cefda16bcde56419814869f3e3500751b9d92fccde1da0</div>
307
  <p>2. <span data-i18n="lc_l2"></span></p>
308
  <button class="secbtn" id="gogo" data-i18n="gd_go"></button>
309
  <details style="margin-top:16px"><summary data-i18n="lc_one"></summary>
 
298
  <div class="card checker addrguide" id="guide" style="margin-top:18px">
299
  <h2 data-i18n="lc_lh"></h2>
300
  <p>1. <span data-i18n="lc_l1"></span></p>
301
+ <div class="row"><a class="secbtn dl" href="local/keyguard-local.ps1" download="keyguard-local-v2.ps1" data-i18n="lc_lw"></a><a class="sl" href="https://huggingface.co/spaces/FINAL-Bench/KeyGuard/blob/main/local/keyguard-local.ps1" target="_blank" rel="noopener" data-i18n="lc_src"></a></div>
302
+ <div class="gl"><span data-i18n="lc_run"></span> Β· PowerShell</div><textarea id="runwin" class="cmd" readonly rows="2">powershell -ExecutionPolicy Bypass -File "$HOME\Downloads\keyguard-local-v2.ps1"</textarea><button class="secbtn cp" data-for="runwin" data-i18n="gd_copy"></button>
303
+ <div class="gl hs">SHA-256 5efac92df5f2ecfd887a495e4475e44060c5bad229d0d8bc8b8d08092be1e8a0</div>
304
+ <div class="row"><a class="secbtn dl" href="local/keyguard-local.py" download="keyguard-local-v2.py" data-i18n="lc_lp"></a><a class="sl" href="https://huggingface.co/spaces/FINAL-Bench/KeyGuard/blob/main/local/keyguard-local.py" target="_blank" rel="noopener" data-i18n="lc_src"></a></div>
305
+ <div class="gl"><span data-i18n="lc_run"></span> Β· Terminal</div><textarea id="runnix" class="cmd" readonly rows="2">python3 ~/Downloads/keyguard-local-v2.py</textarea><button class="secbtn cp" data-for="runnix" data-i18n="gd_copy"></button>
306
+ <div class="gl hs">SHA-256 1d79cea414535dea8c8ba7e020e020c9e3bb5407d842d885c1d6746c3b349152</div>
307
  <p>2. <span data-i18n="lc_l2"></span></p>
308
  <button class="secbtn" id="gogo" data-i18n="gd_go"></button>
309
  <details style="margin-top:16px"><summary data-i18n="lc_one"></summary>
local/keyguard-local.ps1 CHANGED
@@ -1,9 +1,9 @@
1
  ο»Ώ# KeyGuard Local for Windows (PowerShell 5.1 or 7): check the RSA PUBLIC keys of devices in your own private network and print the verdict.
2
  #
3
- # powershell -ExecutionPolicy Bypass -File .\keyguard-local.ps1
4
- # powershell -ExecutionPolicy Bypass -File .\keyguard-local.ps1 -Hosts 192.168.0.1,192.168.0.20
5
  #
6
- # What it does: TCP connect, one TLS handshake per open port (and ssh-keyscan on port 22 when available).
7
  # What it never does: no login attempts, no private keys, no internet traffic, no upload. The verdict is computed here and the key file stays on this computer.
8
  # The same file can also be opened in the Self-check tab of https://huggingface.co/spaces/FINAL-Bench/KeyGuard (checked inside your browser).
9
  # Use it only on networks and devices you own or are authorized to test. MIT License, VIDRAFT.
@@ -101,15 +101,44 @@ function Get-CertPem([string]$ip, [int]$port) {
101
  return "-----BEGIN CERTIFICATE-----`n" + $b.TrimEnd() + "`n-----END CERTIFICATE-----"
102
  } catch { return $null } finally { $c.Close() }
103
  }
104
- function Get-SshRsa([string]$ip) {
105
- $x = Get-Command ssh-keyscan -ErrorAction SilentlyContinue
106
- if (-not $x) { return $null }
 
 
 
 
 
 
 
 
 
 
 
 
107
  try {
108
- $ErrorActionPreference = 'Continue'
109
- $o = & $x.Source -t rsa -T 4 $ip 2>$null
110
- $m = [regex]::Match(($o -join "`n"), 'ssh-rsa [A-Za-z0-9+/=]+')
111
- if ($m.Success) { return $m.Value }
112
- } catch { }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  return $null
114
  }
115
 
@@ -123,6 +152,7 @@ else {
123
  }
124
  if ($Ports.Count -gt 5 -or $list.Count -gt 256 -or $list.Count -eq 0) { Write-Host 'At most 5 ports and 256 addresses.'; exit 1 }
125
  if (@($list | Where-Object { -not (Test-PrivateIp $_) }).Count) { Write-Host 'Only private addresses are allowed (10.x, 172.16-31.x, 192.168.x).'; exit 1 }
 
126
  Write-Host ("Target: {0} to {1} ({2} addresses), ports {3}" -f $list[0], $list[-1], $list.Count, ($Ports -join ','))
127
  if (-not $Yes) {
128
  Write-Host 'Use this only on a network you own or are authorized to test.'
@@ -147,7 +177,7 @@ Write-Host ("Open ports: {0}" -f $open.Count)
147
  $lines = @('# KeyGuard Local: public keys only'); $keys = @(); $rows = @()
148
  foreach ($t in $open) {
149
  $lab = '{0}:{1}' -f $t.ip, $t.port
150
- $k = if ($t.port -eq 22) { Get-SshRsa $t.ip } else { Get-CertPem $t.ip $t.port }
151
  $v = $null
152
  if ($k) { $lines += "# $lab"; $lines += $k; $v = Get-RsaKey $k }
153
  if ($v) { $keys += [pscustomobject]@{ lab = $lab; n = $v.n; e = $v.e; share = @() } }
 
1
  ο»Ώ# KeyGuard Local for Windows (PowerShell 5.1 or 7): check the RSA PUBLIC keys of devices in your own private network and print the verdict.
2
  #
3
+ # powershell -ExecutionPolicy Bypass -File .\keyguard-local-v2.ps1
4
+ # powershell -ExecutionPolicy Bypass -File .\keyguard-local-v2.ps1 -Hosts 192.168.0.1,192.168.0.20
5
  #
6
+ # What it does: TCP connect, a TLS handshake per open port (on port 22 the SSH key exchange, up to the host key).
7
  # What it never does: no login attempts, no private keys, no internet traffic, no upload. The verdict is computed here and the key file stays on this computer.
8
  # The same file can also be opened in the Self-check tab of https://huggingface.co/spaces/FINAL-Bench/KeyGuard (checked inside your browser).
9
  # Use it only on networks and devices you own or are authorized to test. MIT License, VIDRAFT.
 
101
  return "-----BEGIN CERTIFICATE-----`n" + $b.TrimEnd() + "`n-----END CERTIFICATE-----"
102
  } catch { return $null } finally { $c.Close() }
103
  }
104
+ $Group14 = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF'
105
+ $Group1 = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF'
106
+ $Kex = [ordered]@{ 'diffie-hellman-group14-sha256' = $Group14; 'diffie-hellman-group14-sha1' = $Group14; 'diffie-hellman-group1-sha1' = $Group1 }
107
+ function Get-Rand([int]$n) { $b = New-Object byte[] $n; $r = [Security.Cryptography.RandomNumberGenerator]::Create(); $r.GetBytes($b); $r.Dispose(); return , $b }
108
+ function ConvertTo-U32([int]$n) { return , [byte[]]@((($n -shr 24) -band 255), (($n -shr 16) -band 255), (($n -shr 8) -band 255), ($n -band 255)) }
109
+ function ConvertFrom-U32([byte[]]$b, [int]$i) { return ([int]$b[$i] -shl 24) + ([int]$b[$i + 1] -shl 16) + ([int]$b[$i + 2] -shl 8) + $b[$i + 3] }
110
+ function Read-Exact($st, [int]$n) { $b = New-Object byte[] $n; $k = 0; while ($k -lt $n) { $r = $st.Read($b, $k, $n - $k); if ($r -le 0) { throw 'closed' }; $k += $r }; return , $b }
111
+ function Read-SshPacket($st) { $n = ConvertFrom-U32 (Read-Exact $st 4) 0; if ($n -lt 2 -or $n -gt 40000) { throw 'bad packet' }; $b = Read-Exact $st $n; return , (Get-Sub $b 1 ($n - 1 - $b[0])) }
112
+ function Send-SshPacket($st, [byte[]]$body) {
113
+ $pad = 8 - (($body.Length + 5) % 8); if ($pad -lt 4) { $pad += 8 }
114
+ $m = [byte[]]((ConvertTo-U32 ($body.Length + $pad + 1)) + [byte]$pad + $body + (Get-Rand $pad)); $st.Write($m, 0, $m.Length); $st.Flush()
115
+ }
116
+ function Get-SshRsa([string]$ip, [int]$port) {
117
+ # RSA host key of an SSH server. Runs the key exchange up to the host key and disconnects: no login step.
118
+ $c = New-Object Net.Sockets.TcpClient
119
  try {
120
+ if (-not $c.ConnectAsync($ip, $port).Wait(3000)) { return $null }
121
+ $c.ReceiveTimeout = 5000; $c.SendTimeout = 5000; $st = $c.GetStream(); $line = ''
122
+ for ($q = 0; $q -lt 20; $q++) { $line = ''; while (-not $line.EndsWith("`n") -and $line.Length -lt 512) { $line += [char](Read-Exact $st 1)[0] }; if ($line.StartsWith('SSH-')) { break } }
123
+ if (-not $line.StartsWith('SSH-')) { return $null }
124
+ $v = [Text.Encoding]::ASCII.GetBytes("SSH-2.0-KeyGuardLocal`r`n"); $st.Write($v, 0, $v.Length)
125
+ $enc = 'aes128-ctr,aes256-ctr,aes128-cbc,3des-cbc'; $mac = 'hmac-sha2-256,hmac-sha2-512,hmac-sha1'
126
+ $body = [byte[]](@([byte]20) + (Get-Rand 16))
127
+ foreach ($x in (($Kex.Keys) -join ','), 'rsa-sha2-512,rsa-sha2-256,ssh-rsa', $enc, $enc, $mac, $mac, 'none', 'none', '', '') { $a = [Text.Encoding]::ASCII.GetBytes($x); $body = [byte[]]($body + (ConvertTo-U32 $a.Length) + $a) }
128
+ Send-SshPacket $st ([byte[]]($body + [byte[]](0, 0, 0, 0, 0)))
129
+ $b = Read-SshPacket $st; while ($b[0] -ne 20) { $b = Read-SshPacket $st }
130
+ $theirs = [Text.Encoding]::ASCII.GetString($b, 21, (ConvertFrom-U32 $b 17)).Split(',')
131
+ $name = $Kex.Keys | Where-Object { $theirs -contains $_ } | Select-Object -First 1
132
+ if (-not $name) { return $null }
133
+ $p = $Big::Parse('0' + $Kex[$name], [Globalization.NumberStyles]::HexNumber)
134
+ $e = $Big::ModPow((New-Object System.Numerics.BigInteger 2), (ConvertTo-Big (Get-Rand 32)), $p)
135
+ $raw = $e.ToByteArray(); [Array]::Reverse($raw)
136
+ Send-SshPacket $st ([byte[]](@([byte]30) + (ConvertTo-U32 $raw.Length) + $raw))
137
+ for ($q = 0; $q -lt 6; $q++) {
138
+ $b = Read-SshPacket $st
139
+ if ($b[0] -eq 31) { $k = Get-Sub $b 5 (ConvertFrom-U32 $b 1); if ([Text.Encoding]::ASCII.GetString($k, 4, 7) -eq 'ssh-rsa') { return 'ssh-rsa ' + [Convert]::ToBase64String($k) }; return $null }
140
+ }
141
+ } catch { return $null } finally { $c.Close() }
142
  return $null
143
  }
144
 
 
152
  }
153
  if ($Ports.Count -gt 5 -or $list.Count -gt 256 -or $list.Count -eq 0) { Write-Host 'At most 5 ports and 256 addresses.'; exit 1 }
154
  if (@($list | Where-Object { -not (Test-PrivateIp $_) }).Count) { Write-Host 'Only private addresses are allowed (10.x, 172.16-31.x, 192.168.x).'; exit 1 }
155
+ Write-Host 'KeyGuard Local v2'
156
  Write-Host ("Target: {0} to {1} ({2} addresses), ports {3}" -f $list[0], $list[-1], $list.Count, ($Ports -join ','))
157
  if (-not $Yes) {
158
  Write-Host 'Use this only on a network you own or are authorized to test.'
 
177
  $lines = @('# KeyGuard Local: public keys only'); $keys = @(); $rows = @()
178
  foreach ($t in $open) {
179
  $lab = '{0}:{1}' -f $t.ip, $t.port
180
+ $k = if ($t.port -eq 22) { Get-SshRsa $t.ip $t.port } else { Get-CertPem $t.ip $t.port }
181
  $v = $null
182
  if ($k) { $lines += "# $lab"; $lines += $k; $v = Get-RsaKey $k }
183
  if ($v) { $keys += [pscustomobject]@{ lab = $lab; n = $v.n; e = $v.e; share = @() } }
local/keyguard-local.py CHANGED
@@ -2,16 +2,16 @@
2
  # -*- coding: utf-8 -*-
3
  """KeyGuard Local: check the RSA PUBLIC keys of devices in your own private network and print the verdict.
4
 
5
- python3 keyguard-local.py # scan the /24 of this computer (asks first)
6
- python3 keyguard-local.py --hosts 192.168.0.1,192.168.0.20
7
- python3 keyguard-local.py --ports 443,8443,22 --out keyguard_keys.txt
8
 
9
- What it does: TCP connect, one TLS handshake per open port (and ssh-keyscan on port 22 when available).
10
  What it never does: no login attempts, no private keys, no internet traffic, no upload. The verdict is computed here and the key file stays on this computer.
11
  The same file can also be opened in the Self-check tab of https://huggingface.co/spaces/FINAL-Bench/KeyGuard (checked inside your browser).
12
  Use it only on networks and devices you own or are authorized to test. Standard library only. MIT License, VIDRAFT.
13
  """
14
- import argparse, base64, ipaddress, locale, math, os, re, shutil, socket, ssl, subprocess, sys
15
  from concurrent.futures import ThreadPoolExecutor
16
 
17
  NETS = [ipaddress.ip_network(n) for n in ("10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "127.0.0.0/8")]
@@ -64,16 +64,73 @@ def cert(ip, port):
64
  return None
65
 
66
 
 
 
 
 
 
67
  def ssh_rsa(ip, port):
68
- exe = shutil.which("ssh-keyscan")
69
- if not exe:
70
- return None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  try:
72
- out = subprocess.run([exe, "-t", "rsa", "-T", "4", "-p", str(port), ip], capture_output=True, text=True, timeout=12).stdout
73
- except (OSError, subprocess.SubprocessError):
74
- return None
75
- m = re.search(r"ssh-rsa ([A-Za-z0-9+/=]+)", out)
76
- return m.group(0) if m else None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
 
79
  KO = (os.environ.get("LANG") or (locale.getlocale()[0] or "")).lower().startswith(("ko", "korean"))
@@ -211,6 +268,7 @@ def main():
211
  sys.exit("At most 5 ports and 256 addresses.")
212
  if not all(h.version == 4 and private(h) for h in hosts):
213
  sys.exit("Only private addresses are allowed (10.x, 172.16-31.x, 192.168.x).")
 
214
  print("Target: %s%s (%d addresses), ports %s" % (hosts[0], " to %s" % hosts[-1] if len(hosts) > 1 else "", len(hosts), ports))
215
  if not a.yes:
216
  print("Use this only on a network you own or are authorized to test.\n본인 μ†Œμœ μ΄κ±°λ‚˜ 점검 κΆŒν•œμ΄ μžˆλŠ” λ„€νŠΈμ›Œν¬μ—μ„œλ§Œ μ‚¬μš©ν•˜μ‹­μ‹œμ˜€.")
 
2
  # -*- coding: utf-8 -*-
3
  """KeyGuard Local: check the RSA PUBLIC keys of devices in your own private network and print the verdict.
4
 
5
+ python3 keyguard-local-v2.py # scan the /24 of this computer (asks first)
6
+ python3 keyguard-local-v2.py --hosts 192.168.0.1,192.168.0.20
7
+ python3 keyguard-local-v2.py --ports 443,8443,22 --out keyguard_keys.txt
8
 
9
+ What it does: TCP connect, a TLS handshake per open port (on port 22 the SSH key exchange, up to the host key).
10
  What it never does: no login attempts, no private keys, no internet traffic, no upload. The verdict is computed here and the key file stays on this computer.
11
  The same file can also be opened in the Self-check tab of https://huggingface.co/spaces/FINAL-Bench/KeyGuard (checked inside your browser).
12
  Use it only on networks and devices you own or are authorized to test. Standard library only. MIT License, VIDRAFT.
13
  """
14
+ import argparse, base64, ipaddress, locale, math, os, socket, ssl, sys
15
  from concurrent.futures import ThreadPoolExecutor
16
 
17
  NETS = [ipaddress.ip_network(n) for n in ("10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "127.0.0.0/8")]
 
64
  return None
65
 
66
 
67
+ GROUP14 = "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF"
68
+ GROUP1 = "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF"
69
+ KEX = {"diffie-hellman-group14-sha256": GROUP14, "diffie-hellman-group14-sha1": GROUP14, "diffie-hellman-group1-sha1": GROUP1}
70
+
71
+
72
  def ssh_rsa(ip, port):
73
+ """RSA host key of an SSH server. Runs the key exchange up to the host key and disconnects: no login step."""
74
+ def st(b):
75
+ return len(b).to_bytes(4, "big") + b
76
+
77
+ def send(body):
78
+ pad = 8 - (len(body) + 5) % 8
79
+ pad += 8 if pad < 4 else 0
80
+ s.sendall((len(body) + pad + 1).to_bytes(4, "big") + bytes([pad]) + body + os.urandom(pad))
81
+
82
+ def need(n):
83
+ b = b""
84
+ while len(b) < n:
85
+ c = s.recv(n - len(b))
86
+ if not c:
87
+ raise OSError("closed")
88
+ b += c
89
+ return b
90
+
91
+ def packet():
92
+ n = int.from_bytes(need(4), "big")
93
+ if not 2 <= n <= 40000:
94
+ raise OSError("bad packet")
95
+ b = need(n)
96
+ return b[1:n - b[0]]
97
+
98
  try:
99
+ with socket.create_connection((ip, port), 4) as s:
100
+ s.settimeout(5)
101
+ for _ in range(20):
102
+ line = b""
103
+ while not line.endswith(b"\n") and len(line) < 512:
104
+ line += need(1)
105
+ if line.startswith(b"SSH-"):
106
+ break
107
+ else:
108
+ return None
109
+ s.sendall(b"SSH-2.0-KeyGuardLocal\r\n")
110
+ hk = b"rsa-sha2-512,rsa-sha2-256,ssh-rsa"
111
+ enc = b"aes128-ctr,aes256-ctr,aes128-cbc,3des-cbc"
112
+ mac = b"hmac-sha2-256,hmac-sha2-512,hmac-sha1"
113
+ send(b"\x14" + os.urandom(16) + b"".join(st(x) for x in (",".join(KEX).encode(), hk, enc, enc, mac, mac, b"none", b"none", b"", b"")) + b"\x00" * 5)
114
+ b = packet()
115
+ while b[:1] != b"\x14":
116
+ b = packet()
117
+ n = int.from_bytes(b[17:21], "big")
118
+ theirs = b[21:21 + n].decode("ascii", "replace").split(",")
119
+ kex = next((k for k in KEX if k in theirs), None)
120
+ if not kex:
121
+ return None
122
+ e = pow(2, int.from_bytes(os.urandom(32), "big") | 1 << 255, int(KEX[kex], 16))
123
+ raw = e.to_bytes(e.bit_length() // 8 + 1, "big")
124
+ send(b"\x1e" + st(raw))
125
+ for _ in range(6):
126
+ b = packet()
127
+ if b[:1] == b"\x1f":
128
+ n = int.from_bytes(b[1:5], "big")
129
+ key = b[5:5 + n]
130
+ return "ssh-rsa " + base64.b64encode(key).decode() if key[4:11] == b"ssh-rsa" else None
131
+ except (OSError, ValueError, IndexError):
132
+ pass
133
+ return None
134
 
135
 
136
  KO = (os.environ.get("LANG") or (locale.getlocale()[0] or "")).lower().startswith(("ko", "korean"))
 
268
  sys.exit("At most 5 ports and 256 addresses.")
269
  if not all(h.version == 4 and private(h) for h in hosts):
270
  sys.exit("Only private addresses are allowed (10.x, 172.16-31.x, 192.168.x).")
271
+ print("KeyGuard Local v2")
272
  print("Target: %s%s (%d addresses), ports %s" % (hosts[0], " to %s" % hosts[-1] if len(hosts) > 1 else "", len(hosts), ports))
273
  if not a.yes:
274
  print("Use this only on a network you own or are authorized to test.\n본인 μ†Œμœ μ΄κ±°λ‚˜ 점검 κΆŒν•œμ΄ μžˆλŠ” λ„€νŠΈμ›Œν¬μ—μ„œλ§Œ μ‚¬μš©ν•˜μ‹­μ‹œμ˜€.")