etc.git


etc

~ scripts and random things
git clone https://github.com/djnnvx/etc.git
log | files | refs | archive

main.go (1341B)

      1 package main
      2 
      3 import (
      4 	"fmt"
      5 	"os"
      6 
      7 	"github.com/arch-mage/mdb"
      8 	"github.com/spf13/cobra"
      9 )
     10 
     11 var (
     12 	mdbFilepath string
     13 )
     14 
     15 const version = "0.0.1"
     16 const ASCII_ART = `
     17 
     18         \    /\
     19  mdbls   )  ( ')
     20   ---   (  /  )
     21  ~djnn   \(__)|         v0.0.1
     22 
     23 ------------------------------------------------
     24       simple cli to find out which columns of
     25          a .mdb file are worth looking at
     26 
     27        ===> evil.djnn.sh/djnn/mdb-ls  <===
     28 ------------------------------------------------
     29 
     30 `
     31 
     32 var rootCmd = &cobra.Command{
     33 	Use:   "mdb-ls",
     34 	Short: "simple cli to find out which columns of a .mdb file are worth looking at",
     35 	Long:  ASCII_ART,
     36 	Run: func(cmd *cobra.Command, args []string) {
     37 
     38 		if mdbFilepath == "" {
     39 			println("[!] mbdFilepath is not specified.")
     40 			os.Exit(1)
     41 		}
     42 
     43 		file, err := os.Open(mdbFilepath)
     44 		if err != nil {
     45 			panic(err)
     46 		}
     47 		defer file.Close()
     48 
     49 		tables, err := mdb.Tables(file)
     50 		if err != nil {
     51 			panic(err)
     52 		}
     53 
     54 		fmt.Printf("[+] Found %d tables....\n", len(tables))
     55 		for _, table := range tables {
     56 
     57 			if table.Sys {
     58 				println("SYS table found....skipping")
     59 				continue
     60 			}
     61 
     62 			if len(table.Columns) != 0 {
     63 				fmt.Printf("\t%s => %d columns", table.Name, len(table.Columns))
     64 			}
     65 		}
     66 	},
     67 }
     68 
     69 func main() {
     70 
     71 	rootCmd.Flags().StringVarP(&mdbFilepath, "file", "f", "", ".mdb file path")
     72 	rootCmd.ExecuteC()
     73 
     74 }