daily pastebin goal
48%
SHARE
TWEET

TheHackerNews.com SlackBot

MauricioCorrea Oct 28th, 2016 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #
  2. #Change This:
  3. $URL_Slack_Hook = "https://hooks.slack.com/services/XXXXXXX/XXXXXXXX/XXXXXXXXXXXXXXXXX";
  4. #
  5. $DB = "C:\Windows\Temp\thehackernews_bot.tmp";
  6. #
  7. #
  8.  
  9. #Not Change This
  10. $url_hacker_news = "http://feeds.feedburner.com/TheHackersNews?format=xml";
  11.  
  12. $TMP_DB = Get-Content $DB;
  13.  
  14. Write-Host "############################################";
  15. Write-Host "#####      TheHackerNews SlackBot      #####";
  16. Write-Host "######### Powered By XLabs Security ########";
  17. Write-Host "#########      www.xlabs.com.br     ########";
  18. Write-Host "############################################";
  19.  
  20. [xml]$hack_content = Invoke-WebRequest -Uri $url_hacker_news;
  21.  
  22. $Feed = $hack_content.rss.channel;
  23.  
  24. $Array = @();
  25.  
  26.  
  27. foreach($msg in $Feed.Item){
  28.  
  29.     $title = $msg.title -replace "\?\?\?","-";
  30.     $data0 = $msg.pubDate -replace ",","";
  31.     $data0 = $data0 -replace "PDT", "";
  32.  
  33.     $OriginalLink = $msg.origLink;
  34.  
  35.     $IMGLink = $msg.thumbnail.url -replace "s72-c","s450-c350";
  36.    
  37.    
  38.     $data = [datetime]::Parse($data0, [CultureInfo]::GetCultureInfo("en-US"));
  39.    #$data = $msg.pubDate;
  40.    
  41.    # " Descrição: " $msg.description "Categoria:" $msg.category
  42.  
  43.    $dt=[datetime]::Now;
  44.  
  45.    if(($data.Day -eq $dt.Day) -and ($data.Month -eq $dt.Month)){
  46.    
  47.         if($TMP_DB -contains $data0){
  48.        
  49.         Write-Host "Contém " $data0;
  50.  
  51.         }else{
  52.  
  53.                Write-Host "####################################";
  54.                Write-Host "Data: " $data;
  55.                Write-Host "Title: " $title;
  56.                Write-Host "Autor: " $msg.author;
  57.                Write-Host "Link: " $msg.origLink;
  58.                Write-Host "IMG-Link: " $IMGLink;
  59.  
  60.                   $Text = "<$OriginalLink>";
  61.  
  62.                   $IMG = "https://lh5.ggpht.com/SctfJkxSfr2q7VUZ6TOuFrzyK-p6-lPSZz9Yv6ooaWcehSSLfkFcpKN0MFPfhFvq1bk=w300";
  63.                  
  64.                   $body = "{`"username`": `"TheHackerNewsBot`",
  65.                          `"text`": `"$title (SlackBot Powered By <https://www.xlabs.com.br/|XLabs Security>)`", `"unfurl_links`": true, `"icon_url`": `"$IMG`", `"attachments`": [ { `"title`": `"$title`", `"title_link`": `"$OriginalLink`", `"image_url`": `"$IMGLink`", `"color`": `"#7CD197`" } ] }";
  66.  
  67.                   $URL_POST = $URL_Slack_Hook;
  68.          
  69.                   $Retorno = Invoke-RestMethod -Method POST -Uri $URL_POST -Body $body;
  70.  
  71.                  
  72.                   Write-Host "Postado no Slack.com";
  73.                   Write-Host "####################################";
  74.          }
  75.  
  76.    }
  77.  
  78.    $Array += $data0;
  79.  
  80. }
  81. $Array | Out-File $DB;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top