Monday, October 3, 2016

macOS Sierra: Facebook: Post Using PHP

Command:

$ cat /Library/WebServer/Documents/fb-tokens/index.php


Result:

<?php
print_r($_GET);

?>


URL (Get code):

https://graph.facebook.com/oauth/authorize?client_id=MY_APP_ID&scope=publish_actions&redirect_uri=http://localhost/fb-tokens/


Result:

Array ( [code] => MY_CODE )


URL (GET access token):

https://graph.facebook.com/oauth/access_token?client_id=MY_APP_ID&redirect_uri=http://localhost/fb-tokens/&client_secret=MY_APP_SECRET&code=MY_CODE


Result:

access_token=MY_ACCESS_TOKEN&expires=5176951


Command:

$ cat posttest.php


Result:

<?php
require_once __DIR__ . '/vendor/autoload.php';
require_once("vendor/facebook/php-sdk/src/Facebook/Facebook.php");
use Facebook\Facebook;

$config = array();
$config['app_id'] = 'MY_APP_ID';
$config['app_secret'] = 'MY_APP_SECRET';
$config['fileUpload'] = false; // optional

$fb = new Facebook($config);
 
$params = array(
"access_token" => "MY_ACCESS_TOKEN",
"message" => "My first post using php",
"link" => "http://nautil.us/issue/40/learning/is-artificial-intelligence-permanently-inscrutable",
"picture" => "http://static.nautil.us/10275_3ac01363eb96084101c0e5ed8be7374a.png",
"name" => "Is Artificial Intelligence Permanently Inscrutable?",
"caption" => "nautil.us",
"description" => "Despite new biology-like tools, some insist interpretation is impossible."
);
               
// post to Facebook
try {
$ret = $fb->post('/me/feed', $params);
echo 'Successfully posted to Facebook';
} catch(Exception $e) {
echo $e->getMessage();
}
?>

Facebook Platform: Dashboard Settings for Retrieving Access Token on Local Server

App Domains: localhost
Site URL: http://localhost/

macOS Sierra: Apache: Enable PHP and User Directory

Command:

$ sudo vi /etc/apache2/httpd.conf
$ diff /etc/apache2/httpd.conf.original /etc/apache2/httpd.conf


Result:

166c166
< #LoadModule userdir_module libexec/apache2/mod_userdir.so
---
> LoadModule userdir_module libexec/apache2/mod_userdir.so
169c169
< #LoadModule php5_module libexec/apache2/libphp5.so
---
> LoadModule php5_module libexec/apache2/libphp5.so


Command:

$ sudo apachectl restart

PHP: Installing Facebook SDK for PHP using Composer

Command:

$ cat composer.json


Result:

{
 "require" : {
  "facebook/php-sdk" : "*"
 }
}


Command:

$ php composer.phar install


Result:

Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing facebook/php-sdk (5.3.1)
    Downloading: 100%      

facebook/php-sdk suggests installing guzzlehttp/guzzle (Allows for implementation of the Guzzle HTTP client)
Package facebook/php-sdk is abandoned, you should avoid using it. Use facebook/graph-sdk instead.
Writing lock file
Generating autoload files


Command:

$ tree vendor/


Result:

vendor/
├── autoload.php
├── composer
│   ├── ClassLoader.php
│   ├── LICENSE
│   ├── autoload_classmap.php
│   ├── autoload_files.php
│   ├── autoload_namespaces.php
│   ├── autoload_psr4.php
│   ├── autoload_real.php
│   ├── autoload_static.php
│   └── installed.json
└── facebook
    └── php-sdk
        ├── LICENSE
        ├── composer.json
        ├── phpcs.xml.dist
        └── src
            └── Facebook
                ├── Authentication
                │   ├── AccessToken.php
                │   ├── AccessTokenMetadata.php
                │   └── OAuth2Client.php
                ├── Exceptions
                │   ├── FacebookAuthenticationException.php
                │   ├── FacebookAuthorizationException.php
                │   ├── FacebookClientException.php
                │   ├── FacebookOtherException.php
                │   ├── FacebookResponseException.php
                │   ├── FacebookResumableUploadException.php
                │   ├── FacebookSDKException.php
                │   ├── FacebookServerException.php
                │   └── FacebookThrottleException.php
                ├── Facebook.php
                ├── FacebookApp.php
                ├── FacebookBatchRequest.php
                ├── FacebookBatchResponse.php
                ├── FacebookClient.php
                ├── FacebookRequest.php
                ├── FacebookResponse.php
                ├── FileUpload
                │   ├── FacebookFile.php
                │   ├── FacebookResumableUploader.php
                │   ├── FacebookTransferChunk.php
                │   ├── FacebookVideo.php
                │   └── Mimetypes.php
                ├── GraphNodes
                │   ├── Birthday.php
                │   ├── Collection.php
                │   ├── GraphAchievement.php
                │   ├── GraphAlbum.php
                │   ├── GraphApplication.php
                │   ├── GraphCoverPhoto.php
                │   ├── GraphEdge.php
                │   ├── GraphEvent.php
                │   ├── GraphGroup.php
                │   ├── GraphList.php
                │   ├── GraphLocation.php
                │   ├── GraphNode.php
                │   ├── GraphNodeFactory.php
                │   ├── GraphObject.php
                │   ├── GraphObjectFactory.php
                │   ├── GraphPage.php
                │   ├── GraphPicture.php
                │   ├── GraphSessionInfo.php
                │   └── GraphUser.php
                ├── Helpers
                │   ├── FacebookCanvasHelper.php
                │   ├── FacebookJavaScriptHelper.php
                │   ├── FacebookPageTabHelper.php
                │   ├── FacebookRedirectLoginHelper.php
                │   └── FacebookSignedRequestFromInputHelper.php
                ├── Http
                │   ├── GraphRawResponse.php
                │   ├── RequestBodyInterface.php
                │   ├── RequestBodyMultipart.php
                │   └── RequestBodyUrlEncoded.php
                ├── HttpClients
                │   ├── FacebookCurl.php
                │   ├── FacebookCurlHttpClient.php
                │   ├── FacebookGuzzleHttpClient.php
                │   ├── FacebookHttpClientInterface.php
                │   ├── FacebookStream.php
                │   ├── FacebookStreamHttpClient.php
                │   ├── HttpClientsFactory.php
                │   └── certs
                │       └── DigiCertHighAssuranceEVRootCA.pem
                ├── PersistentData
                │   ├── FacebookMemoryPersistentDataHandler.php
                │   ├── FacebookSessionPersistentDataHandler.php
                │   ├── PersistentDataFactory.php
                │   └── PersistentDataInterface.php
                ├── PseudoRandomString
                │   ├── McryptPseudoRandomStringGenerator.php
                │   ├── OpenSslPseudoRandomStringGenerator.php
                │   ├── PseudoRandomStringGeneratorFactory.php
                │   ├── PseudoRandomStringGeneratorInterface.php
                │   ├── PseudoRandomStringGeneratorTrait.php
                │   └── UrandomPseudoRandomStringGenerator.php
                ├── SignedRequest.php
                ├── Url
                │   ├── FacebookUrlDetectionHandler.php
                │   ├── FacebookUrlManipulator.php
                │   └── UrlDetectionInterface.php
                ├── autoload.php
                └── polyfills.php

16 directories, 89 files



PHP: Composer: Downloading and Installing Composer

Command:

$ wget -O composer-setup.php https://getcomposer.org/installer


Result:

--2016-10-03 17:22:22--  https://getcomposer.org/installer
Resolving getcomposer.org... 2001:41d0:a:7b19::2, 87.98.253.108
Connecting to getcomposer.org|2001:41d0:a:7b19::2|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 293630 (287K) [application/octet-stream]
Saving to: ‘composer-setup.php’

composer-setup.php         100%[=======================================>] 286.75K   185KB/s    in 1.5s  

2016-10-03 17:22:26 (185 KB/s) - ‘composer-setup.php’ saved [293630/293630]


Command:

$ php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"


Result:

Installer verified


Command:

$ php composer-setup.php


Result:

All settings correct for using Composer
Downloading 1.2.1...

Composer successfully installed to: /Users/USERNAME/composer.phar
Use it: php composer.phar

Python: ONIOFF - Onion URL Inspector: Installing and Running

Command:

$ git clone https://github.com/k4m4/onioff


Result:

Cloning into 'onioff'...
remote: Counting objects: 57, done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 57 (delta 30), reused 52 (delta 25), pack-reused 0
Unpacking objects: 100% (57/57), done.


Command:

$ cd onioff
$ ls


Result:

CHANGES.rst README.rst onioff.py requirements.txt
LICENSE VERSION reports termcolor.py


Command:

$ cat requirements.txt


Result:

requests
pysocks


Command:

$ pip install -r requirements.txt


Result:

Collecting requests (from -r requirements.txt (line 1))
  Downloading requests-2.11.1-py2.py3-none-any.whl (514kB)
    100% |████████████████████████████████| 522kB 1.5MB/s
Collecting pysocks (from -r requirements.txt (line 2))
  Downloading PySocks-1.5.7.tar.gz
Collecting beautifulsoup4 (from -r requirements.txt (line 3))
  Downloading beautifulsoup4-4.5.1-py2-none-any.whl (83kB)
    100% |████████████████████████████████| 92kB 4.1MB/s
Building wheels for collected packages: pysocks
  Running setup.py bdist_wheel for pysocks ... done
  Stored in directory: /Users/USERNAME/Library/Caches/pip/wheels/cf/81/67/77884514e566867d5223e5530e27ce9b9433b78c766a400313
Successfully built pysocks
Installing collected packages: requests, pysocks, beautifulsoup4
Successfully installed beautifulsoup4-4.5.1 pysocks-1.5.7 requests-2.11.1


Command:

$ python onioff.py -h


Result:

 ██████╗ ███╗   ██╗██╗ ██████╗ ███████╗███████╗
██╔═══██╗████╗  ██║██║██╔═══██╗██╔════╝██╔════╝
██║   ██║██╔██╗ ██║██║██║   ██║█████╗  █████╗
██║   ██║██║╚██╗██║██║██║   ██║██╔══╝  ██╔══╝
╚██████╔╝██║ ╚████║██║╚██████╔╝██║     ██║
 ╚═════╝ ╚═╝  ╚═══╝╚═╝ ╚═════╝ ╚═╝     ╚═╝ v0.1

          Onion URL Inspector (ONIOFF)        
  Made With <3 by: Nikolaos Kamarinakis (k4m4)
                  Version: 0.1                
Usage: python onioff.py {onion} [options]

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -f FILE, --file=FILE  onion filename
  -o OUTPUT_FILE, --output=OUTPUT_FILE
                        output filename

Examples:
  python onioff.py http://xmh57jrzrnw6insl.onion/
  python onioff.py -f ~/onions.txt -o ~/report.txt
  python onioff.py https://facebookcorewwwi.onion/ -o ~/report.txt


Command:

$ python onioff.py -f ~/onions.txt -o ~/report.txt


Result:

 ██████╗ ███╗   ██╗██╗ ██████╗ ███████╗███████╗
██╔═══██╗████╗  ██║██║██╔═══██╗██╔════╝██╔════╝
██║   ██║██╔██╗ ██║██║██║   ██║█████╗  █████╗
██║   ██║██║╚██╗██║██║██║   ██║██╔══╝  ██╔══╝
╚██████╔╝██║ ╚████║██║╚██████╔╝██║     ██║
 ╚═════╝ ╚═╝  ╚═══╝╚═╝ ╚═════╝ ╚═╝     ╚═╝ v0.1

          Onion URL Inspector (ONIOFF)        
  Made With <3 by: Nikolaos Kamarinakis (k4m4)
                  Version: 0.1                

[+] Commencing Onion Inspection
[-] Tor Offline --> Please Make Sure Tor Is Running
[-] System Exit




Sunday, October 2, 2016

ユニケージ開発手法: Tukubai: self Command Examples

Command:

$ echo $(date +%Y%m%d%H%M%S) /dir1 http://www.apple.com | self 1.9.2 3.8 2.2


Result:

08 www.apple.com dir1