Skip to content

Commit

Permalink
more examples in te-tag-query-java/README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Aug 10, 2019
1 parent 822c9a8 commit 2c32896
Showing 1 changed file with 44 additions and 5 deletions.
49 changes: 44 additions & 5 deletions hashing/te-tag-query-java/README.md
@@ -1,8 +1,8 @@
Example technique for retrieving all hashes with a given tag from ThreatExchange.
Example technique for retrieving hashes with a given tag from ThreatExchange, as well as uploading.

# Purpose of this code

You can use this for downloading hashes from ThreatExchange, found by tag. You can use the Java code as-is, or use it to illuminate tooling in other languages. Note that `java TETagQuery -s ...` will print the URLs this tool constructs for you, to help make clear how to access ThreatExchange via URLs.
You can use this for downloading/uploading hashes from/to ThreatExchange, found by tag. You can use the Java code as-is, or use it to illuminate tooling in other languages. Note that `java TETagQuery -s ...` will print the URLs this tool constructs for you, to help make clear how to access ThreatExchange via URLs.

# Query mechanism

Expand All @@ -20,13 +20,15 @@ lot.
javac com/facebook/threatexchange/*.java
```

# Running the code

Examples:
# Examples of using the code

On-line help:
```
java com.facebook.threatexchange.TETagQuery --help
```

Querying for all hashes of a given type:
```
java com.facebook.threatexchange.TETagQuery tag-to-details --hash-type pdq media_type_photo
java com.facebook.threatexchange.TETagQuery -v tag-to-details --hash-type pdq media_type_photo
Expand All @@ -40,6 +42,43 @@ java com.facebook.threatexchange.TETagQuery tag-to-details \
media_type_long_hash_video
```

Querying for some hashes of a given type:
```
java com.facebook.threatexchange.TETagQuery tag-to-details --hash-type pdq --since -1day media_type_photo
java com.facebook.threatexchange.TETagQuery tag-to-details --hash-type md5 --since -1week media_type_video
java com.facebook.threatexchange.TETagQuery tag-to-details \
--page-size 10 \
--hash-dir ./tmk-hash-dir \
--hash-type tmk \
--since -1week \
media_type_long_hash_video
```

Post a new TMK hash:

```
java com.facebook.threatexchange.TETagQuery \
submit \
-i ../tmk/sample-hashes/chair-22-sd-sepia-bar.tmk \
-t HASH_TMK \
-d "testing te-tag-query with post" \
-l AMBER \
-s MALICIOUS \
-p HAS_WHITELIST \
--privacy-members 1064060413755420 \
--tags testing_java_post
```

# Setup

* Find your app's access token at https://developers.facebook.com/tools/accesstoken/

* Put this into `~/.txtoken` and `chmod 600 ~/.txtoken`

* `export TX_ACCESS_TOKEN=$(cat ~/.txtoken)` in your shell's init file

# Contact

threatexchange@fb.com

0 comments on commit 2c32896

Please sign in to comment.