From 35ec71b72707d63f6bcb25e646bc3d5a8fba20e1 Mon Sep 17 00:00:00 2001 From: Gwen Date: Thu, 17 Nov 2022 14:47:07 +0100 Subject: [PATCH] license&readme --- GitHubSearch.php | 6 -- LICENSE.md | 21 +++++ README.md | 39 ++++++++-- Utils.php | 6 -- git-history.py | 3 - git-pillage.py | 4 - github-contributors.py | 3 - github-dorks.py | 3 - github-employees.py | 3 - github-endpoints.py | 3 - github-search.php | 24 +++--- github-secrets.py | 3 - github-subdomains.py | 3 - github-survey/index.php | 168 +++++++++++++++++++++------------------- 14 files changed, 151 insertions(+), 138 deletions(-) create mode 100644 LICENSE.md diff --git a/GitHubSearch.php b/GitHubSearch.php index 5765837..cc94a69 100755 --- a/GitHubSearch.php +++ b/GitHubSearch.php @@ -1,11 +1,5 @@ github-search -Most of these scripts require a GitHub token. If you're lazy like me, you can create a `.tokens` file in the cloned repo directory with 1 token per line. +

A collection of tools to perform searches on GitHub.

+ +

+ python badge + MIT license badge + twitter badge +

+ +

+ github stars badge + github watchers badge + github forks badge +

+ +--- + +## Install + +``` +git clone https://github.com/gwen001/github-search +cd github-search +pip3 install -r requirements.txt +``` + +Most of the time GitHub requies a token to perform searches. +You can create a `.tokens` file in the cloned repo directory with 1 token per line +OR +You can configure an environment variable like this: `GIHTHUB_TOKEN=token1,token2,...` + +## Usage Documentation here: http://10degres.net/github-tools-collection/ -I don't believe in license. -You can do whatever you want with this program. -Anyway there is a way to support :) +--- -Sponsor gwen001 +Feel free to [open an issue](/../../issues/) if you have any problem with the script. -Found a bug? Feel free to open an issue https://github.com/gwen001/github-search/issues diff --git a/Utils.php b/Utils.php index 787b2f8..21e63e3 100755 --- a/Utils.php +++ b/Utils.php @@ -1,11 +1,5 @@ setFilename( $v ); break; - + case 'h': Utils::help(); break; - + case 'l': $gsearch->setLanguage( $v ); break; - + case 'm': $gsearch->searchCommit( true ); break; - + case 'n': $gsearch->setColorOutput( false ); break; - + case 'o': $gsearch->setOrganization( $v ); break; - + case 'p': $gsearch->setRepository( $v ); break; - + case 'r': $gsearch->setMaxResult( $v ); break; @@ -97,7 +91,7 @@ function __autoload( $c ) { Utils::help( 'Unknown option: '.$k ); } } - + if( !$gsearch->getString() && !$gsearch->getFilename() ) { Utils::help( 'Search param not found, provide at least a filename or a string' ); } @@ -115,7 +109,7 @@ function __autoload( $c ) { } else { $cnt_result = $gsearch->run(); } - + if( $cnt_result ) { $gsearch->printResult(); } diff --git a/github-secrets.py b/github-secrets.py index 4f3b910..e0e985e 100755 --- a/github-secrets.py +++ b/github-secrets.py @@ -1,8 +1,5 @@ #!/usr/bin/python3 -# I don't believe in license. -# You can do whatever you want with this program. - import os import sys import re diff --git a/github-subdomains.py b/github-subdomains.py index 3c9702d..fe06bae 100755 --- a/github-subdomains.py +++ b/github-subdomains.py @@ -1,8 +1,5 @@ #!/usr/bin/python3 -# I don't believe in license. -# You can do whatever you want with this program. - import os import sys import re diff --git a/github-survey/index.php b/github-survey/index.php index ba7e99e..87d90da 100644 --- a/github-survey/index.php +++ b/github-survey/index.php @@ -105,31 +105,31 @@ function __urlencode( $d ) { return $d; } -function doSearchGithub( $dork, $page ) -{ - global $t_tokens; - - $token = $t_tokens[ rand(0,count($t_tokens)-1) ]; - $t_headers = [ 'Authorization: token '.$token, 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36' ]; - $url = 'https://api.github.com/search/code?sort=indexed&order=desc&page=' . $page . '&q=' . __urlencode($dork); - // echo $url."
\n"; - - $c = curl_init(); - curl_setopt( $c, CURLOPT_URL, $url ); - curl_setopt( $c, CURLOPT_RETURNTRANSFER, true ); - curl_setopt( $c, CURLOPT_HTTPHEADER, $t_headers ); - $r = curl_exec( $c ); - curl_close( $c ); - - // var_dump( $r ); - $t_json = json_decode( $r, true ); - - if( !isset($t_json['total_count']) ) { - return false; - } else { - return $t_json; - } -} +// function doSearchGithub( $dork, $page ) +// { +// global $t_tokens; + +// $token = $t_tokens[ rand(0,count($t_tokens)-1) ]; +// $t_headers = [ 'Accept: application/vnd.github.v3+json', 'Authorization: token '.$token, 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36' ]; +// $url = 'https://api.github.com/search/code?sort=indexed&order=desc&page=' . $page . '&q=' . __urlencode($dork); +// // echo $url."
\n"; + +// $c = curl_init(); +// curl_setopt( $c, CURLOPT_URL, $url ); +// curl_setopt( $c, CURLOPT_RETURNTRANSFER, true ); +// curl_setopt( $c, CURLOPT_HTTPHEADER, $t_headers ); +// $r = curl_exec( $c ); +// curl_close( $c ); + +// // var_dump( $r ); +// $t_json = json_decode( $r, true ); + +// if( !isset($t_json['total_count']) ) { +// return false; +// } else { +// return $t_json; +// } +// } function excludeFusion( $t_config, $dork ) { @@ -226,53 +226,53 @@ function isFiltered( $result, $t_exclude, $t_filters ) return false; } -function getCode( $url ) -{ - global $t_tokens; - - $token = $t_tokens[ rand(0,count($t_tokens)-1) ]; - $t_headers = [ 'Authorization: token '.$token, 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36' ]; - - $c = curl_init(); - curl_setopt( $c, CURLOPT_URL, $url ); - curl_setopt( $c, CURLOPT_RETURNTRANSFER, true ); - curl_setopt( $c, CURLOPT_HTTPHEADER, $t_headers ); - $r = curl_exec( $c ); - curl_close( $c ); - - // var_dump( $r ); - $t_config = json_decode( $r, true ); - - if( !isset($t_config['sha']) ) { - return false; - } else { - return base64_decode( str_replace('\n','',$t_config['content']) ); - } -} - -function getCommitDate( $url ) -{ - global $t_tokens; - - $token = $t_tokens[ rand(0,count($t_tokens)-1) ]; - $t_headers = [ 'Authorization: token '.$token, 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36' ]; - - $c = curl_init(); - curl_setopt( $c, CURLOPT_URL, $url ); - curl_setopt( $c, CURLOPT_RETURNTRANSFER, true ); - curl_setopt( $c, CURLOPT_HTTPHEADER, $t_headers ); - $r = curl_exec( $c ); - curl_close( $c ); - - // var_dump( $r ); - $t_config = json_decode( $r, true ); - - if( !isset($t_config['sha']) ) { - return false; - } else { - return $t_config['committer']['date']; - } -} +// function getCode( $url ) +// { +// global $t_tokens; + +// $token = $t_tokens[ rand(0,count($t_tokens)-1) ]; +// $t_headers = [ 'Accept: application/vnd.github.v3+json', 'Authorization: token '.$token, 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36' ]; + +// $c = curl_init(); +// curl_setopt( $c, CURLOPT_URL, $url ); +// curl_setopt( $c, CURLOPT_RETURNTRANSFER, true ); +// curl_setopt( $c, CURLOPT_HTTPHEADER, $t_headers ); +// $r = curl_exec( $c ); +// curl_close( $c ); + +// // var_dump( $r ); +// $t_config = json_decode( $r, true ); + +// if( !isset($t_config['sha']) ) { +// return false; +// } else { +// return base64_decode( str_replace('\n','',$t_config['content']) ); +// } +// } + +// function getCommitDate( $url ) +// { +// global $t_tokens; + +// $token = $t_tokens[ rand(0,count($t_tokens)-1) ]; +// $t_headers = [ 'Accept: application/vnd.github.v3+json', 'Authorization: token '.$token, 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36' ]; + +// $c = curl_init(); +// curl_setopt( $c, CURLOPT_URL, $url ); +// curl_setopt( $c, CURLOPT_RETURNTRANSFER, true ); +// curl_setopt( $c, CURLOPT_HTTPHEADER, $t_headers ); +// $r = curl_exec( $c ); +// curl_close( $c ); + +// // var_dump( $r ); +// $t_config = json_decode( $r, true ); + +// if( !isset($t_config['sha']) ) { +// return false; +// } else { +// return $t_config['committer']['date']; +// } +// } function getCommitDates( &$t_filtered ) { @@ -283,7 +283,7 @@ function getCommitDates( &$t_filtered ) foreach( $t_filtered as &$result ) { $token = $t_tokens[ rand(0,count($t_tokens)-1) ]; - $t_headers = [ 'Authorization: token '.$token, 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36' ]; + $t_headers = [ 'Accept: application/vnd.github.v3+json', 'Authorization: token '.$token, 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36' ]; $commit_id = explode( '=', $result['url'] )[1]; $result['commit_url'] = $result['repository']['url'] . '/git/commits/' . $commit_id; @@ -330,7 +330,7 @@ function getCodes( &$t_filtered ) foreach( $t_filtered as &$result ) { $token = $t_tokens[ rand(0,count($t_tokens)-1) ]; - $t_headers = [ 'Authorization: token '.$token, 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36' ]; + $t_headers = [ 'Accept: application/vnd.github.v3+json', 'Authorization: token '.$token, 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36' ]; $result['curl'] = curl_init( $result['git_url'] ); curl_setopt( $result['curl'], CURLOPT_RETURNTRANSFER, true ); @@ -370,8 +370,10 @@ function getPagesResults( $dork, $max_page ) for( $p=0 ; $p<$max_page ; $p++ ) { $token = $t_tokens[ rand(0,count($t_tokens)-1) ]; - $t_headers = [ 'Authorization: token '.$token, 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36' ]; + $t_headers = [ 'Accept: application/vnd.github.v3+json', 'Authorization: token '.$token, 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36' ]; $url = 'https://api.github.com/search/code?sort=indexed&order=desc&page=' . $p . '&q=' . __urlencode($dork); + // var_dump($url); + // exit(); $t_curl[$p] = curl_init( $url ); curl_setopt( $t_curl[$p], CURLOPT_RETURNTRANSFER, true ); @@ -407,13 +409,13 @@ function getPagesResults( $dork, $max_page ) } -if( isset($_GET['d']) && isset($t_config['github_dorks'][$_GET['d']]) ) +if( isset($_GET['d']) /*&& isset($t_config['github_dorks'][$_GET['d']])*/ ) { $n_desired = 0; // $current_page = 0; $max_page = isset($_GET['p']) ? (int)$_GET['p'] : DEFAULT_MAX_PAGE; - if( !is_array($t_config['github_dorks'][$_GET['d']]) ) { + if( !isset($t_config['github_dorks'][$_GET['d']]) || !is_array($t_config['github_dorks'][$_GET['d']]) ) { $t_config['github_dorks'][$_GET['d']] = [ 'title' => 'github search code \'' . $_GET['d'] . '\'', 'info' => 'https://github.com/search?o=desc&s=indexed&type=Code&q=' . urlencode($_GET['d']), @@ -537,6 +539,7 @@ function getPagesResults( $dork, $max_page ) body { margin-left: 15px; margin-top: 15px; + font-size: 0.8rem; } .result { margin-bottom: 20px; @@ -548,6 +551,10 @@ function getPagesResults( $dork, $max_page ) } .result_path { + } + .result_clear { + clear: both; + margin-bottom: 5px; } .result_size { font-size: 0.8em; @@ -560,7 +567,7 @@ function getPagesResults( $dork, $max_page ) border: 1px solid #CCC; border-radius: 3px; font-size: 0.8em; - max-height: 300px; + max-height: 200px; margin-bottom: 0px; overflow: scroll; padding: 10px; @@ -623,8 +630,8 @@ function getPagesResults( $dork, $max_page )
- - + + @@ -638,6 +645,7 @@ function getPagesResults( $dork, $max_page ) ()
+