Mini Tips

página en destrucción




contenidos migrándose a https://github.com/cpantel/playground

 

 Find not me

nmap -p 22 192.168.1.100-110 -oG - --open --exclude $(ifconfig | grep "inet addr" | grep -ve 127.0.0.1 | cut -d":" -f 2 | cut -d " " -f 1)| grep "Ports:" ; #FIND SSH NOT ME

nmap  192.168.1.100-110 --exclude $(ifconfig | grep "inet addr" | grep -ve 127.0.0.1 | cut -d":" -f 2 | cut -d " " -f 1) | awk 'BEGIN {} /^Nmap scan.*/ { IP=$5; print IP " up"} /.*open.*/ {print  "                " $1 " " $3}' ; #FIND ANY NOT ME


Time to turn off all the machines

# netmap.txt is a file with mac addresses and data like:


# MAC address : interface : device : brand : user
#
# xx:xx:xx:xx:xx:xx : wifi     : tablet  : samsung : robert
# yy:yy:yy:yy:yy:yy : ethernet : netbook : hp      : *

# zz:zz:zz:zz:zz:zz : wifi     : netbook : hp      : *

#

MAP=netmap.txt
HOSTS=$(findSSHNotMe.sh | cut -d" " -f 2)
REG=$( for HOST in $HOSTS; do echo -n "-e $HOST "; done )

if [ -n "$REG" ] ; then
  arp -a | grep $REG | cut -d " " -f 2,4 | while read PAIR; do
    read IP MAC  <<< $PAIR
    echo -n "IP: $IP DATA: "
    grep -i $MAC "$MAP" || echo " <<< NOT FOUND >>>"
  done

fi

# the ouput would be something like this:
# IP: (192.168.1.109) DATA: xx:xx:xx:xx:xx:xx : wifi : tablet : samsung : robert

# and then

ssh -t user@ip "sudo shutdown -h now"




Remove metadata from pdf with java



build.sh
run.bat
run.sh
MANIFEST.MF
lib/
   commons-logging-1.1.jar
   log4j-1.2.13.jar
   pdfbox-1.8.10.jar
metadata/
    ModifyMetadata.java

[run.bat]
java -jar modifyMetadata.jar %1 %2

[run.sh]
java -jar modifyMetadata.jar $1 $2

[build.sh]
javac -cp lib/pdfbox-1.8.10.jar metadata/ModifyMetadata.java
jar cvfm modifyMetadata.jar MANIFEST.MF metadata/ModifyMetadata.class

[MANIFEST.MF]
Manifest-Version: 1.0
Created-By: 1.7.0 (Sun Microsystems Inc.)
Main-Class: metadata.ModifyMetadata
Class-Path: lib/pdfbox-1.8.10.jar lib/commons-logging-1.1.jar lib/log4j-1.2.13.jar


[Metatada.java]

package metadata;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDDocumentInformation;

public class ModifyMetadata {
  private ModifyMetadata() { }
  public static void main( String[] args ) throws Exception {
    if( args.length != 2 ) {
      usage();
    } else {
 

      try {
        PDDocument document = PDDocument.load( args[0] );
        if( document.isEncrypted() ) {
          System.err.println( "Error: Cannot modify encrypted document." );
          System.exit( 1 );
        }
        PDDocumentInformation info = document.getDocumentInformation();

        info.setAuthor("Your stamp");
        info.setProducer("Your stamp");
        info.setKeywords("Your stamp");
        info.setCreator("Your stamp");
        info.setSubject("Your stamp");
        info.setTitle("Your stamp");
        document.save( args[1] );
      } finally {
        if( document != null ) {
          document.close();
        }
      }
    }
  }
  private static void usage() {
    System.err.println( "Usage: java metadata.ModifyMetadata " +
      "<input-pdf> <output-pdf>" );
  }
}



No hay comentarios:

Publicar un comentario