Results 1 to 14 of 14

Thread: Useful scripts and one-liners

  1. #1
    Join Date
    Jul 2007
    Location
    Austria
    Posts
    1,336

    Post Useful scripts and one-liners

    Viele verwenden den Router seit Jahren mit verschiedenen Anwendungen.
    Ich stelle hier meine Scripte und Einzeiler für alle User zur Verfügung und rufe auch andere User dazu auf.
    Bitte nur getestete Scripts und Einzeiler posten. Für Fragen bitte unbedingt einen anderen Thread öffnen - Danke.
    Ein guter Platz zum speichern der Scripte ist /tmp/local/bin oder /opt/bin oder /opt/sbin.
    Bitte die Rechte der Scripte auf 755 setzen !

    Many of us use the router for years with various applications.
    I present here my scripts and one-liners for all users and call other users to do the same.
    Please post just well tested scripts and one-liners. For questions please open a new thread - thank you.
    A good place to store the scripts is /tmp/local/bin or /opt/bin or /opt/sbin
    Please set the rights of scripts to 755 !

    List of scripts and one-liners (alphabetical order)

    Name Beschreibung / Description

    avbf Schutz vor brute force Angriff (nur AP Mode), avoid brute force in AP Mode German english
    getip zeigt die IP's vom Interface an, shows you the ip of any interface
    getrepo Speichere das gesamte Repository, download a complete repository
    lcom Liste alle Commandos vom Router, list all commands on router
    symlinks Zeige symbolische Links in Verzeichnissen, list symbolic links of directories
    shorten Kürzt Config Files, shorten config-files
    Einzeiler1 Ein Image einer ganzen Partition via ssh auf einen enternten Rechner. Store a complete image of a partition via ssh on a remote machine.
    Portscan Make a list of Portscan from Logfile
    Last edited by newbiefan; 09-04-2012 at 11:23.
    Alle HowTo's, all howto's

    RT-N16 1.9.2.7-rtn-r3121, Samba, VSFTP, Lightthpd, PHP, Perl, MySQL, Serendipity, Aria2web, HDD 640GB
    RT-N66U, 16GB MicroSD/ 2 Partitions, 2,5" HDD 1TB, running with Merlin's FW and Entware, 16 Mbit A1,
    Netgear DGND 3700V2, QNAP TS119PII 4 TB, QNAP TS209 2 TB Raid1, Backup Synology DS107+ 1 TB, HP CP1515n

  2. #2
    Join Date
    Jul 2007
    Location
    Austria
    Posts
    1,336

    script avbf

    Der Script avbf schützt sie vor Angriffe aus dem Internet (Port 21 & 22) wenn der Asus im AP Mode hinter einem Modem/Router
    hängt. Entpacken sie den Script auf ihrem PC. Speichern sie den Script am Router. Die Datei hosts.deny speichern sie am
    Router nach /opt/etc/host.deny
    Nun tragen sie den Aufruf des Scripts in /tmp/local/sbin/post-mount unmittelbar vor dem Aufruf von rc.unslung ein.
    Wenn sie einen anderen Speicherort für ihre host.deny Datei verwenden, ändern sie die entsprechende Variable in avbf.
    Die verwendete host.deny Datei sperrt den gesamten Asien-pazifischen Raum sowie einige auf Afrika und wenige
    besonders lästige Script-Kiddies aus den USA, meist nur College oder Unis. Beobachten sie ihren Logfile besonders genau -
    wenn sie gefährliche oder wiederkehrende Angreifer finden, fragen sie einfach "whois ip" auf der Kommandozeile.
    Tragen sie die gesamte IP-Range/Netmask (cidr) in die hosts.deny Datei ein. Nach einem Neustart ist auch diese Ip-Range
    gesperrt. Weiters sollten sie gelegentlich ein "iptables -nvL" ausführen und nachsehen, aus welcher IP-Range besonders
    viele (natürlich) sinnlose Zugriffe erfolgten. Wenn aus einer IP-Range sehr lange keine versuchten Zugriffe erfolgt sind,
    können diese in der hosts.deny Datei ausgetragen werden. Ein probates Hilfsmittel wird der etwas später gepostet Script
    ipts sein, die Ausgabe iptables -nvL wird in einer eigens angelegten Datei gespeichert (Datum_und_Uhrzeit).
    Manchmals taucht die Frage auf, daß whois nicht auf dem Router sei - lol - hier müssen sie das Repo bemühen.

    Bitte kontrollieren sie den Pfad (Variable) im Script avbf auf die Richtigkeit des Speierortes von ipt_recent. Die verschiedenen Versionen der FW haben auch unterschiedliche Speicherorte.
    Viel Spass

    Diese Version ist für Kernel 2.4!
    Attached Files Attached Files
    Last edited by newbiefan; 09-04-2012 at 14:26.
    Alle HowTo's, all howto's

    RT-N16 1.9.2.7-rtn-r3121, Samba, VSFTP, Lightthpd, PHP, Perl, MySQL, Serendipity, Aria2web, HDD 640GB
    RT-N66U, 16GB MicroSD/ 2 Partitions, 2,5" HDD 1TB, running with Merlin's FW and Entware, 16 Mbit A1,
    Netgear DGND 3700V2, QNAP TS119PII 4 TB, QNAP TS209 2 TB Raid1, Backup Synology DS107+ 1 TB, HP CP1515n

  3. #3
    Join Date
    Jul 2007
    Location
    Austria
    Posts
    1,336

    Script getip

    getip zeigt ihnen die IP-Adresse vom gewünschten Interface an. Wenn sie nicht wissen sollten, welche Interfaces
    verfügbar sind, geben sie nur getip ein. Syntax: getip br0 (oder irgend ein gültiges Interface)

    getip shows you the ip of a valid interface. If you don't know which interfaces are available, just enter getip.
    Syntax: getip br0

    Viel Spass - have fun

    Diese Version ist für Kernel 2.4 und Kernel 2.6
    Attached Files Attached Files
    Last edited by newbiefan; 09-04-2012 at 14:27.
    Alle HowTo's, all howto's

    RT-N16 1.9.2.7-rtn-r3121, Samba, VSFTP, Lightthpd, PHP, Perl, MySQL, Serendipity, Aria2web, HDD 640GB
    RT-N66U, 16GB MicroSD/ 2 Partitions, 2,5" HDD 1TB, running with Merlin's FW and Entware, 16 Mbit A1,
    Netgear DGND 3700V2, QNAP TS119PII 4 TB, QNAP TS209 2 TB Raid1, Backup Synology DS107+ 1 TB, HP CP1515n

  4. #4
    Join Date
    Jul 2007
    Location
    Austria
    Posts
    1,336

    Script getrepo

    Zieht ein komplettes Repository (optware) und speichert es auf ihrer HDD im Ordner /tmp/mnt/disc0_3/repository. Dazu wird
    automatisch ein Unterordner mit dem Datum und Zeit als Name erstellt. Syntax: getrepo &

    A complete repository is downloaded and stored onto your hdd in directory /tmp/mnt/disc0_3/repostitory. Further, a subdir is
    created with date and time as name. Syntax: getrepo &

    Viel Spass - have fun

    Diese Version ist für Kernel 2.4
    Attached Files Attached Files
    Last edited by newbiefan; 09-04-2012 at 14:27.
    Alle HowTo's, all howto's

    RT-N16 1.9.2.7-rtn-r3121, Samba, VSFTP, Lightthpd, PHP, Perl, MySQL, Serendipity, Aria2web, HDD 640GB
    RT-N66U, 16GB MicroSD/ 2 Partitions, 2,5" HDD 1TB, running with Merlin's FW and Entware, 16 Mbit A1,
    Netgear DGND 3700V2, QNAP TS119PII 4 TB, QNAP TS209 2 TB Raid1, Backup Synology DS107+ 1 TB, HP CP1515n

  5. #5
    Join Date
    Jul 2007
    Location
    Austria
    Posts
    1,336

    Script lcom

    Listet alle verfügbaren Kommandos des Routers auf. Berücksichtigen sie, dass manchmal eine Umleitung der Ausgabe sehr
    nützlich ist. Dadurch können sie in Ruhe die verfügbaren Befehle studieren.
    Syntax: lcom oder lcom > /tmp/kommandos.txt

    Lists all available commands of the router. Consider that a redirection of stdout is sometimes very useful. This allows
    you a deeper study of available commands.
    Syntax: lcom or lcom > /tmp/commands.txt


    EDIT:
    Wenn jemand die coreutils usw. Doppelanzeige nicht sehen will, einfach: lcom | grep -v - > /tmp/kommandos.txt
    If a user don't want to see the double-output of coreutils aso. just use: lcom | grep -v - > /tmp/commands.txt


    Viel Spass - have fun

    Diese Version ist für Kernel 2.4 und Kernel 2.6
    Attached Files Attached Files
    Last edited by newbiefan; 09-04-2012 at 14:28.
    Alle HowTo's, all howto's

    RT-N16 1.9.2.7-rtn-r3121, Samba, VSFTP, Lightthpd, PHP, Perl, MySQL, Serendipity, Aria2web, HDD 640GB
    RT-N66U, 16GB MicroSD/ 2 Partitions, 2,5" HDD 1TB, running with Merlin's FW and Entware, 16 Mbit A1,
    Netgear DGND 3700V2, QNAP TS119PII 4 TB, QNAP TS209 2 TB Raid1, Backup Synology DS107+ 1 TB, HP CP1515n

  6. #6
    Join Date
    Jul 2007
    Location
    Austria
    Posts
    1,336

    Script symlinks

    Script symlinks
    Zeigt alle symbolischen Links des jeweiligen oder beliebigen Verzeichnisses an. Jeder Profi weiss, wie schwierig man
    sinnlose symbolische Links wieder los wird.
    Syntax: symlinks zeigt die symb. Links des verwendeten Verzeichnisses
    symlinks /opt/sbin usw.
    ACHTUNG: Bitte nicht die Wurzel nehmen (/) dann besteht die Möglichkeit, dass sich der Script aufhängt.

    Shows all symolic links of the/or any directory. Any professional knows how hard it is to remove senseless symbolic links.
    Syntax: symlinks shows sybolic links of the current directory
    symlinks /opt/sbin a.s.o. shows you symbolic links of any directory

    Viel Spass - have fun

    Diese Version ist für Kernel 2.4
    Attached Files Attached Files
    Last edited by newbiefan; 09-04-2012 at 14:29.
    Alle HowTo's, all howto's

    RT-N16 1.9.2.7-rtn-r3121, Samba, VSFTP, Lightthpd, PHP, Perl, MySQL, Serendipity, Aria2web, HDD 640GB
    RT-N66U, 16GB MicroSD/ 2 Partitions, 2,5" HDD 1TB, running with Merlin's FW and Entware, 16 Mbit A1,
    Netgear DGND 3700V2, QNAP TS119PII 4 TB, QNAP TS209 2 TB Raid1, Backup Synology DS107+ 1 TB, HP CP1515n

  7. #7
    Join Date
    Jul 2007
    Location
    Austria
    Posts
    1,336

    Script shorten

    Diesen Script habe ich bereits länger in Verwendung. Er entfernt alle Leerzeilen und Bemerkungen. Das ist speziell für
    erfahrene User sehr nützlich, man erhält von z.Bspl. Config-Files eine sehr kurze Konfigurationsdatei und für einen
    erfahrenen Benutzer sind die Parameter und Variablen das Wesentliche.
    Syntax shorten /opt/etc/man.conf

    I use this script since years. The script removes all blank lines and remarks. Especially for experienced users it is
    mostly very helpful, for instance, you get a very short config-file. Particulary a well experienced user needs just the
    essentials like parameters and variables.
    Syntax: shorten /opt/etc/man.conf

    Viel Spass - have fun

    Diese Version ist für Kernel 2.4 und Kernel 2.6
    Attached Files Attached Files
    Last edited by newbiefan; 09-04-2012 at 14:31.
    Alle HowTo's, all howto's

    RT-N16 1.9.2.7-rtn-r3121, Samba, VSFTP, Lightthpd, PHP, Perl, MySQL, Serendipity, Aria2web, HDD 640GB
    RT-N66U, 16GB MicroSD/ 2 Partitions, 2,5" HDD 1TB, running with Merlin's FW and Entware, 16 Mbit A1,
    Netgear DGND 3700V2, QNAP TS119PII 4 TB, QNAP TS209 2 TB Raid1, Backup Synology DS107+ 1 TB, HP CP1515n

  8. #8
    Join Date
    Jul 2007
    Location
    Austria
    Posts
    1,336

    Einzeiler/One-liner Complete image via ssh

    Ein komplettes Image einer Festplatte/Partition kann man in Linux ganz einfach auf einen entfernten Rechner legen.
    Bei mir hat die entfernte QNAP(NAS, ssh Port 2222) die IP 192.168.178.4 - Befehl aufrufen und das Passwort des entfernten
    Rechners eingeben - fertig!
    SSH muss installiert sein.

    A complete Image of a HDD/Partition can easily be stored on a remote machine. In my case, the remote QNAP (NAS, ssh Port 2222) has the IP 192.168.178.4 - enter the command below as well as your password of the remote machine - done!
    SSH has to be installed.

    Code:
    dd if=/dev/discs/disc0/part2 | ssh -p 2222 administrator@192.168.178.4 "dd of=/share/Public/Asus/optware/optware2011.img"
    Viel Spass - have fun


    Diese Version ist für Kernel 2.4 und Kernel 2.6
    Last edited by newbiefan; 09-04-2012 at 14:32.
    Alle HowTo's, all howto's

    RT-N16 1.9.2.7-rtn-r3121, Samba, VSFTP, Lightthpd, PHP, Perl, MySQL, Serendipity, Aria2web, HDD 640GB
    RT-N66U, 16GB MicroSD/ 2 Partitions, 2,5" HDD 1TB, running with Merlin's FW and Entware, 16 Mbit A1,
    Netgear DGND 3700V2, QNAP TS119PII 4 TB, QNAP TS209 2 TB Raid1, Backup Synology DS107+ 1 TB, HP CP1515n

  9. #9
    Join Date
    Jul 2007
    Location
    Austria
    Posts
    1,336

    Count portscan and make lists of logfiles

    Nachstehend finden sie einen Link zum "dirty" Script Portscan, den ich seit einiger Zeit benutze um die Portscans auszuwerten. Natürlich finden sie auch die entsprechenden Auswertungen der ip's.
    Selbstverständlich werde ich die Auswertungen gelegentlich erneuern, soferne auch Interesse besteht.
    Die Zugriffsliste der Hacker ist allerdings dramatisch eingeschränkt, da ich seit langer Zeit meine Ban-Liste mit meinem Script AVBF verwende, deshalb fehlen alle Netzwerke, welche darin vorkommen. In den nächsten Tagen werde ich den Script Portscan erweitern, damit man sehen kann, welche und wieviele IP's (samt Port) mit der Ban-Liste geblockt wurden.
    Wenn sie meinen Script AVBF verwenden wollen, steht ihnen die aktuelle Ban-Liste ebenfalls unter dem Link zur Verfügung. Natürlich können sie die Ban-Liste auch für ihre eigenen Zwecke verwenden. Bitte lesen sie zuerst die Datei readme.txt
    Der Script Portscan wertet automatisch alle Dateien im Ordner /opt/var/log/syslog.log.xxx.gz aus, sofern diese mit dem Script avbf2_6 angelegt wurden. Rufen sie dazu lediglich mit cron jeden Tag den Script auf. Achten sie darauf, dass die im Script definierten Files/Ordner auch angelegt sind. Chmod 755 natürlich nicht vergessen
    Hier der Link: http://www.irauschek.info/asus/blocklists

    Have fun


    Diese Version ist für Kernel 2.6, für Kernel 2.4 wurde der Script portscan nicht getestet
    Last edited by newbiefan; 25-12-2013 at 21:42.
    Alle HowTo's, all howto's

    RT-N16 1.9.2.7-rtn-r3121, Samba, VSFTP, Lightthpd, PHP, Perl, MySQL, Serendipity, Aria2web, HDD 640GB
    RT-N66U, 16GB MicroSD/ 2 Partitions, 2,5" HDD 1TB, running with Merlin's FW and Entware, 16 Mbit A1,
    Netgear DGND 3700V2, QNAP TS119PII 4 TB, QNAP TS209 2 TB Raid1, Backup Synology DS107+ 1 TB, HP CP1515n

  10. #10

    shell script problem, Oleg SW

    kann mir bitte bei dem Script jemand helfen?
    es werden Bilder bei Bewegung (mvc) aufgenommen und via Email (mutt) versandt.
    es funktioniert bestens per terminal online (im Verzeichnis /tmp/var/tmp) Eingabe, aber aus dem script heraus automatisch leider nicht.
    edit: der mvc Teil funktioniert auch auch automatisch; evt. liegt es am -e Paramter Kommando von mvc...

    Was ist da falsch? Danke an die shell scripting Gurus!

    cd /tmp/var/tmp && /tmp/mnt/disc0_1/mvc/bin/mvc -O /tmp/var/tmp -d /dev/v4l/video0 -s 160x120 -D -v -o -t -w 5 -c 200 -e '/opt/bin/mutt `for file in *.jpg; do echo -n "-a /tmp/var/tmp/${file} "; done` -s "TEST" test@test.net < /tmp/mutt_mail_content'
    Last edited by dyonisos; 11-01-2013 at 15:50.

  11. #11
    Code:
    #! /bin/sh
    vergessen?
    Script ausführbar gemacht?

    absolute Pfade hast du ja drin, da würde ich wenn es aus der Shell läuft den Fehler ausschließen :-)

    Statt dem && würde ich die zwei Befehle in zwei unterschiedliche Zeilen setzen, da sie dann eh nacheinander aufgerufen werden und dein Script übersichtlicher wird.

    Vlt. hilft das ja schon
    VG
    !gm
    RT-N66U TomatoUSB 1.28.0000 MIPSR2-135 K26AC USB AIO-64K running Entware-NG
    pyload 0.4.9
    minidlna 1.1.2
    samba 3.6.5
    openvpn 2.3.10
    ̶W̶L̶5̶0̶0̶g̶P̶ ̶1̶.̶9̶.̶2̶.̶7̶-̶r̶t̶n̶-̶r̶4̶7̶5̶0 retired

  12. #12

    shell script funkt nicht

    Hi !gm

    alles so befolgt. geht trotzdem nicht.
    das Problem liegt hier:
    `for file in *.jpg; do echo -n "-a /tmp/var/tmp/${file} "; done`
    das skript verliert den Pfad, beim ersten Durchlauf geht's ja. $file ist dann ab 2. Durchlauf leer...

    mit source ./script.sh klappt es auch nicht.
    von der Kommandozeile läuft es ohne Probleme!

    Danke für jeden guten Tip!
    LG D.
    Last edited by dyonisos; 12-01-2013 at 15:01.

  13. #13
    Code:
    `for file in /tmp/var/tmp/*.jpg usw.
    dann brauchst du das cd auch nicht mehr

    geht das?
    RT-N66U TomatoUSB 1.28.0000 MIPSR2-135 K26AC USB AIO-64K running Entware-NG
    pyload 0.4.9
    minidlna 1.1.2
    samba 3.6.5
    openvpn 2.3.10
    ̶W̶L̶5̶0̶0̶g̶P̶ ̶1̶.̶9̶.̶2̶.̶7̶-̶r̶t̶n̶-̶r̶4̶7̶5̶0 retired

  14. #14
    Quote Originally Posted by !gm View Post
    Code:
    `for file in /tmp/var/tmp/*.jpg usw.
    dann brauchst du das cd auch nicht mehr

    geht das?
    Nein, geht leider nicht. Hatte ich als erstes probiert.

    Warum geht das Ding perfekt von der Kommandozeile (ich starte es mit sh /tmp/mvc) und spinnt als Auto-Script? Also Auto-Script funktioniert der mvc-Teil, der mutt-Teil läuft nicht.

    ich will nicht aufgeben, hab's aber bald satt :-)

    LG D.

Similar Threads

  1. How to execute php scripts ?
    By simistef in forum WL-500gP Q&A
    Replies: 13
    Last Post: 11-03-2008, 10:35
  2. Replies: 0
    Last Post: 11-07-2007, 13:58
  3. IP Start-scripts for IP-UP and IP-DOWN
    By rj.2001 in forum WL-500g Q&A
    Replies: 7
    Last Post: 09-07-2007, 17:14
  4. Post Your Useful Scripts
    By tomilius in forum WL-500g Custom Development
    Replies: 2
    Last Post: 05-06-2005, 11:01
  5. Shell scripts and post-boot
    By samoht in forum WL-500g Q&A
    Replies: 5
    Last Post: 04-06-2005, 00:58

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •