Capture output of ssh connection to SonicWall in vb.net -
i'm surprised isn't out there already, guess needs trailblazer. ok, part of pci compliance firewall rules need reviewed periodically. thought doing right, apparently not. i've been put on correct path , trying automation possible. end, trying connect sonicwall firewall using .net program (specifically vb.net) (that trying write) , execute following command "show nat-policies xml" , capture xml output (i service groups, address objects , address groups), shred in database.
initially, tried ssh.net giving me error connection being closed. little research says ssh.net has issues trying connect sonicwall firewall , should try using tamir.sharpssh. tried that, first attempt, when executed connect statement, waited didn't move past statement. tried second example , complained host keys.
i know sonicwall firewall configured ssh because can connect using putty , information (in convoluted way, can it). here code call hangs:
imports tamir.sharpssh imports tamir.sharpssh.jsch imports system.io imports system.threading imports org.mentalis.security public class form1 private sub form1_load(sender object, e eventargs) handles mybase.load try dim cssh new sshshell("192.168.000.000", "username", "user password") cssh.connect() 'freezes here using sstream sshstream = cssh.getstream() dim wrtr new streamwriter(sstream) dim rdr new streamreader(sstream) wrtr.autoflush = true writestream("show nat-policies xml", wrtr, sstream) readstream(rdr) end using catch ex exception textbox1.text = ex.message textbox1.appendtext(vbcrlf + "finished") end try end sub private sub writestream(byval cmd string, byval wrtr streamwriter, byval sstrm sshstream) wrtr.writeline(cmd) while sstrm.length = 0 thread.sleep(500) end while end sub private sub readstream(byval sreader streamreader) dim line string = sreader.readline() while not string.isnullorempty(line) textbox1.appendtext(vbcrlf + line) line = sreader.readline() end while end sub end class
any ideas?
Comments
Post a Comment