#StackBounty: #wget #curl wget or curl gives 403:Forbidden while downloading file from OneDrive for business

Bounty: 250

I’m trying to download software for a client which resides in my bussiness OneDrive account. Through the webinterface of OneDrive I do:

  • Right click the file and select Share
  • List item
  • Change the link settings to”Anyone with the link”
  • Keep the checkbox at “Allow editing”
  • Copy link

This gives me a link like this:

https://company-my.sharepoint.com/:u:/g/personal/path/lKuaRC_jkBwW9IJo4rOmN8tZju8mePVw?e=lRErX4

When I browse to that link, I’m redirected to a downloadpage where I see a button “Download” so I click Download, open the download center and select “copy download link” so I have the direct download link. When I copy that link to a new private window, I get the option to download the file directly.

When I use that link with curl or wget, I still get a 403:FORBIDDEN

For example, this is the command I use:

wget https://company-my.sharepoint.com/personal/path/to/the/file.aspx?SourceUrl=%2Fpersonal%2Fme%5Fcompany%5Fcountry%2FDocuments%2Fpath%2FSoftware%2FDownloadPackageLocationLinuxSP16%2Etar

and the output:

Resolving company-my.sharepoint.com (company-my.sharepoint.com)... aa.bbb.cc.d
Connecting to company-my.sharepoint.com (company-my.sharepoint.com)|aa.bbb.cc.d|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2020-01-24 14:46:48 ERROR 403: Forbidden.


Get this bounty!!!

#StackBounty: #python #html #shell #download #wget Shell script to download a lot of HTML files and store them statically with all CSS

Bounty: 50

I have posted on a forum of sciences a lot of post (roughly 290 questions) that I would like to get back by downloading them with all the associated answers.

The first issue is that I have to be logged on my personal space to have the list of all the messages. How to circumvent this first barrier to be able with a shell script or a single wget command to get back all URL and their content. Can I pass to wgeta login and a password to be logged and redirected to the appropriate URL ontaining the list of all messages ?

Once this first issue will be solved, the second issue is that I have to start from 6 different menu pages that all contain the title and the link of the questions.

Moreover, concerning some of my questions, the answers and the discussions may be on multiple pages.

So I wonder if I could achieve this operation of global downloading knowing I would like to store them statically with local CSS stored also on my computer (to keep the same format into my browser when I consult them on my PC).

The URL of the first menu page of questions is (once I am logged on the website : that could be an issue also to download with wget if I am obliged to be connected).

An example of URL containing the list of messages, once I am logged, is :

https://forums.futura-sciences.com/search.php?searchid=22897684

the other pages (there all 6 or 7 pages of discussions title in total appering in the main menu page) have the format :
https://forums.futura-sciences.com/search.php?searchid=22897684&pp=&page=2
(for page 2)

https://forums.futura-sciences.com/search.php?searchid=22897684&pp=&page=5
(for page 5)

One can see on each of these pages the title and the link of each of the discussions that I would like to download with also CSS (knowing each discussion may contain multiple pages also) :

for example the first page of discussion “https://forums.futura-sciences.com/archives/804364-demonstration-dilatation-temps.html

has page2 : “https://forums.futura-sciences.com/archives/804364-demonstration-dilatation-temps-2.html

and page 3 : “https://forums.futura-sciences.com/archives/804364-demonstration-dilatation-temps-3.html

Naively, I tried to do all this with only one command : (with the example of URL on my personal space that I have taken at the beginning of post, i.e “https://forums.futura-sciences.com/search.php?searchid=22897684“) :

wget -r --no-check-certificate --html-extension --convert-links "https://forums.futura-sciences.com/search.php?searchid=22897684"

but unfortunately, this command downloads all files, and even maybe not what I want, i.e my discussions.

I don’t know what the approach to use : must I firstly store all URL in a file (with all sub-pages containing all answers and the global discussion for each of mu initial question) ?

and after, I could do maybe a wget -i all_URL_questions.txt

Anyone could give me help to carry out this operation?

UPDATE 1 : my issue needs a script, i tried with python the following things :

1)

import urllib, urllib2, cookielib

username = 'USERNAME'
password = 'PASSWORD'

cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
login_data = urllib.urlencode({'username' : username, 'password' : password})
opener.open('https://forums.futura-sciences.com/login.php', login_data)
resp = opener.open('https://forums.futura-sciences.com/search.php?do=finduser&userid=253205&contenttype=vBForum_Post&showposts=1')
print resp.read()

But the page printed is not the page of my home into personal space.

2)

import requests

# Fill in your details here to be posted to the login form.
payload = { 
    'inUserName': 'USERNAME',
    'inUserPass': 'PASSWORD'
}

# Use 'with' to ensure the session context is closed after use.
with requests.Session() as s:
    p = s.post('https://forums.futura-sciences.com/login.php?do=login', data=payload)
    # print the html returned or something more intelligent to see if it's a successful login page.
    print p.text.encode('utf8')

    # An authorised request.
    r = s.get('https://forums.futura-sciences.com/search.php?do=finduser&userid=253205&contenttype=vBForum_Post&showposts=1')
    print r.text.encode('utf8')

here too, this doesn’t work

3)

import requests
import bs4 

site_url = 'https://forums.futura-sciences.com/login.php?do=login'
userid = 'USERNAME'
password = 'PASSWWORD'

file_url = 'https://forums.futura-sciences.com/search.php?do=finduser&userid=253205&contenttype=vBForum_Post&showposts=1' 
o_file = 'abc.html'  

# create session
s = requests.Session()
# GET request. This will generate cookie for you
s.get(site_url)
# login to site.
s.post(site_url, data={'vb_login_username': userid, 'vb_login_password': password})
# Next thing will be to visit URL for file you would like to download.
r = s.get(file_url)

# Download file
with open(o_file, 'wb') as output:
    output.write(r.content)
print("requests:: File {o_file} downloaded successfully!")

# Close session once all work done
s.close()

Same thing, the content is wrong

4)

from selenium import webdriver

# To prevent download dialog
profile = webdriver.FirefoxProfile()
profile.set_preference('browser.download.folderList', 2) # custom location
profile.set_preference('browser.download.manager.showWhenStarting', False)
profile.set_preference('browser.download.dir', '/tmp')
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/csv')

webdriver.get('https://forums.futura-sciences.com/')
webdriver.find_element_by_id('ID').send_keys('USERNAME')
webdriver.find_element_by_id ('ID').send_keys('PASSWORD')
webdriver.find_element_by_id('submit').click()
browser = webdriver.Firefox()
browser.get('https://forums.futura-sciences.com/search.php?do=finduser&userid=253205&contenttype=vBForum_Post&showposts=1')

Still not getting to log in with USERNAME and PASSSWORD and get content of homepage of personal space

5)

from selenium import webdriver
from selenium.webdriver.firefox.webdriver import FirefoxProfile
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
import time

def MS_login(username, passwd):  # call this with username and password

firefox_capabilities = DesiredCapabilities.FIREFOX
    firefox_capabilities['moz:webdriverClick'] = False
    driver = webdriver.Firefox(capabilities=firefox_capabilities)
    fp = webdriver.FirefoxProfile()
    fp.set_preference("browser.download.folderList", 2) # 0 means to download to the desktop, 1 means to download to the default "Downloads" directory, 2 means to use the directory
    fp.set_preference("browser.download.dir","/Users/user/work_archives_futura/")
    driver.get('https://forums.futura-sciences.com/') # change the url to your website
    time.sleep(5) # wait for redirection and rendering
    driver.delete_all_cookies() # clean up the prior login sessions
    driver.find_element_by_xpath("//input[@name='vb_login_username']").send_keys(username)

elem  = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, "//input[@name='vb_login_password']")))
    elem.send_keys(Keys.TAB)

driver.find_element_by_xpath("//input[@type='submit']").click()

    print("success !!!!")

driver.close() # close the browser
    return driver

if __name__ == '__main__':
    MS_login("USERNAME","PASSWORD")

The window is well opened, username filled but impossible to fill or submit the password and click on submit.

I begin to be discouraged.

ps: the main issue could come from that password field has display:none property, So I can’t simulate TAB operation to password field and pass it, once I have put the login.

Any help is welcome

EDIT 1: Isn’t there really nobody who could provide suggestions ? I know this a little bit tricky but it should exist a solution, at least, I hope…


Get this bounty!!!

#StackBounty: #git #curl #bitbucket #wget Download a File from the Download section of Bitbucket Repo using Access key

Bounty: 50

I’m looking for a way to download a file from bitbucket, (not the repository, a file from download section)
It’s possible to clone repository using deployment key but couldn’t make it for downloads.
I’ve tried those;
curl -u username: --key .ssh/id_rsa --pubkey .ssh/id_rsa.pub scp://bitbucket.org/repositoryowner/downloads/downloadfile.zip

EDIT:
I’ve found a workaround, still there is no way to download using deployment key but with credentials;
wget -O /tmp/file --user "username" --password "password" https://bitbucket.org/owner/rep/downloads/abc.tar.gz


Get this bounty!!!

#StackBounty: #windows-10 #wget #openssl #monitoring Openssl is unable to establish SSL connection, when I try to access a local site t…

Bounty: 50

I want to monitor the index of a site periodically on our local network out of browsers. I tried to download it by wget in Windows10:

> wget --no-check-certificate --no-hsts --content-on-error --ignore-length --unlink --server-response --show-progress --verbose https://172.*.*.*:*/app

But it couldn’t fetch the page. Here is the result:

--2019-02-02 16:56:01--  https://172.*.*.*:*/app
Connecting to 172.*.*.*:*... connected.
OpenSSL: error:2406F079:random number generator:RAND_load_file:Cannot open file
Unable to establish SSL connection.

I also tried with other tools like urlwatch and curl. None of the couldn’t get access to that page! Is there any idea? Here is the error given by urlwatch:

HTTPSConnectionPool(host='172.*.*.*', port=*):
Max retries exceeded with url: /app
(Caused by SSLError(SSLError(1,
'[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1056)')))


Get this bounty!!!

#StackBounty: #wget #openssl #monitoring Openssl is unable to establish SSL connection, when I try to access a local site through third…

Bounty: 50

I want to monitor the index of a site periodically on our local network out of browsers. I tried to download it by wget in Windows10:

> wget --no-check-certificate --no-hsts --content-on-error --ignore-length --unlink --server-response --show-progress --verbose https://172.*.*.*:*/app

But it couldn’t fetch the page. Here is the result:

--2019-02-02 16:56:01--  https://172.*.*.*:*/app
Connecting to 172.*.*.*:*... connected.
OpenSSL: error:2406F079:random number generator:RAND_load_file:Cannot open file
Unable to establish SSL connection.

I also tried with other tools like urlwatch and curl. None of the couldn’t get access to that page! Is there any idea? Here is the error given by urlwatch:

HTTPSConnectionPool(host='172.*.*.*', port=*):
Max retries exceeded with url: /app
(Caused by SSLError(SSLError(1,
'[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1056)')))


Get this bounty!!!