LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > LinuxQuestions.org > LQ Suggestions & Feedback
User Name
Password
LQ Suggestions & Feedback Do you have a suggestion for this site or an idea that will make the site better? This forum is for you.
PLEASE READ THIS FORUM - Information and status updates will also be posted here.

Notices


Reply
  Search this Thread
Old 03-15-2023, 02:39 PM   #166
jrosevear
LQ Newbie
 
Registered: Nov 2006
Distribution: Slackware
Posts: 29

Rep: Reputation: 14
Bingo!


I see, after posting that it works.

I added the extension, then I selected Firefox and Slackware.

I also added "; Slackware15.0" to the end of the string. I'm not sure which of these to things fixed it.
 
Old 03-15-2023, 02:44 PM   #167
jrosevear
LQ Newbie
 
Registered: Nov 2006
Distribution: Slackware
Posts: 29

Rep: Reputation: 14
Changed my mind...

But I would rather not advertise it.
 
Old 03-16-2023, 10:30 AM   #168
vtel57
Senior Member
 
Registered: Jul 2006
Location: USA
Distribution: Slackware64 - 14.2 w/ Xfce
Posts: 1,631

Rep: Reputation: 489Reputation: 489Reputation: 489Reputation: 489Reputation: 489
Quote:
Originally Posted by jrosevear View Post
But I would rather not advertise it.

You'd rather not advertise what? Your operating system?
 
Old 03-16-2023, 12:16 PM   #169
metaed
Member
 
Registered: Apr 2022
Location: US
Distribution: Slackware64 15.0
Posts: 374

Rep: Reputation: 172Reputation: 172
Above in the thread I see conflicting information.
One claim is that the string slackware can be added anywhere to the UA, and that the test is case insensitive.
Another claim is that the string Slackware Linux replaces the string Linux in the UA.
What is the actual comparison done by LQ against the UA? Is a regex documented somewhere?

Last edited by metaed; 03-16-2023 at 01:17 PM.
 
Old 03-16-2023, 12:34 PM   #170
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,927
Blog Entries: 45

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Member Response

Hi,


I use;
Quote:
Mozilla/5.0 (X11; Linux x86_64; rv:111.0) Gecko/20100101 Firefox/ 111.0 Slackware 15.0
 
Old 03-16-2023, 01:07 PM   #171
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,152
Blog Entries: 6

Rep: Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835
https://www.whatismybrowser.com/guid...-agent/firefox
https://www.whatismybrowser.com/guid...r-agent/chrome
 
Old 03-16-2023, 01:19 PM   #172
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 5,767

Rep: Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765
I spend most of my time on agent strings making sure sites CANNOT tell what I am running. The whole concept of letting them KNOW is odd to me.



I mean, considering how they misuse such data.

BTW: you have no control on the client side over how the server end will parse the agent strings. That is under the server admin's control. Most just use some defaults, but even those change as the software updates on the server end. You take your best shot and hope.

Last edited by wpeckham; 03-16-2023 at 01:22 PM.
 
Old 03-16-2023, 02:45 PM   #173
cwizardone
LQ Veteran
 
Registered: Feb 2007
Distribution: Slackware64-current with "True Multilib" and KDE4Town.
Posts: 9,167

Rep: Reputation: 7339Reputation: 7339Reputation: 7339Reputation: 7339Reputation: 7339Reputation: 7339Reputation: 7339Reputation: 7339Reputation: 7339Reputation: 7339Reputation: 7339
FWIW: You can do it on a per web site basis, that is, if you want only Linux Questions to know your Linux distribution, you can do so.

Last edited by cwizardone; 03-16-2023 at 02:49 PM.
 
Old 03-16-2023, 02:46 PM   #174
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,152
Blog Entries: 6

Rep: Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835
Quote:
The whole concept of letting them KNOW is odd to me.
So that you can get the page that you want from a server. Some websites, some video delivery websites, present different pages, with different source, depending on what user agent you report in your header. Some sites will load without scripts on using an iphone user agent, but not with a desktop agent.

It can definitely be advantageous to report yourself as something that you aren't. Youtube for example, you can search, display youtube pages, with a googlebot user agent, and not let scripts run at all. The result or course is a faster, less bandwith, no adds page delivery.

You are not kidding any web server that is using analytics. That's not the ides for me.

Also, presenting a iphone user agent will get you a playlist.m3u8 in the source, because that's how apple devices work. Where as a linux or windows agent won't. They deliver content differently based on device type.

That is the reasoning for user agents for me.

Little test, this site right here, Clouflare!
Use this url:
https://www.linuxquestions.org/quest...12/page12.html

Code:
#!/usr/bin/python

#Get the source with urllib
from urllib import request
#Parse it with soup
from bs4 import BeautifulSoup
#If you want to use args
import sys
#If you want pager in term
from pydoc import pager

#User agent to use
agent1 = ('Mozilla/5.0 (iPhone; CPU iPhone OS 16_2 like Mac OS X)'
        ' AppleWebKit/605.1.15 (KHTML, like Gecko)'
        ' CriOS/108.0.5359.112 Mobile/15E148 Safari/604.1')

agent2 = ('Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0)'
        ' Gecko/20100101 Firefox/109.0')

#Make header for urllib to report
header = {
        'User-Agent': agent1,
        'Accept': 'text/html,application/xhtml+xml,'
        'image/avif,image/webp,image/apng,'
        'application/signed-exchange;v=b3;q=0.9'  
        'application/xml;q=0.9,*/*;q=0.8',
        'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
        'Accept-Language': 'en-US,en;q=0.8',
            #Get a gzip page from server
        #'Accept-Encoding': 'gzip, deflate, br',
        #'Content-type': 'application/json'}
            #urllib will override and send a close
        #'Connection': 'keep-alive'
        }
                
#Simple header
#header = {'User-Agent': agent1}

#Get url of page with input
url = input('Enter/Paste URL :')
#Get url of page with args
#url = str(sys.argv[1])

#Get page, feed it to soup
req = request.Request(url, data=None, headers=header)
html = request.urlopen(req)
soup = BeautifulSoup(html)

#Kill all script and style elements
for script in soup(["script", "style"]):
    script.extract()

#Get text of page
text = soup.get_text()

#Break into lines and remove leading/trailing spaces
lines = (line.strip() for line in text.splitlines())

#Break multi-headlines into a line each
chunks = (phrase.strip() for line in lines for phrase in line.split("  "))

#Drop blank lines, space lines
text = '\n\n'.join(chunk for chunk in chunks if chunk)

#Write file and/or output to term
with open('webpage.txt', 'a') as f:
    f.write(text)

#Pager for scrolling text in terminal with up/down pgUp/pgDown
pager(text)
And you get text of this page to scroll down with the arrow keys.

Ok, now Line 45
Change this:
Code:
req = request.Request(url, data=None, headers=header)
To this:
Code:
req = request.Request(url)
So that no user agent is presented in the header.

And you get
Code:
...
urllib.error.HTTPError: HTTP Error 403: Forbidden
Just my 2 cents for "the why" of manipulating user agents and request headers.

Last edited by teckk; 03-16-2023 at 02:51 PM.
 
Old 03-16-2023, 03:16 PM   #175
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,152
Blog Entries: 6

Rep: Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835
And, if you want to see that in action, what a real web server is seeing from you.
Code:
#!/usr/bin/python

from urllib import request
import http

user_agent = ('Mozilla/5.0 (Windows NT 10.0; Win64 x64; rv:109.0) '
            'Gecko/20100101 Firefox/109.0')

header = {
        'User-Agent': user_agent,
        'Accept': 'text/html,application/xhtml+xml,'
        'image/avif,image/webp,image/apng,'
        'application/signed-exchange;v=b3;q=0.9'  
        'application/xml;q=0.9,*/*;q=0.8',
        'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
        'Accept-Language': 'en-US,en;q=0.8',
        
        #Get a gzip page from server
        #'Accept-Encoding': 'gzip, deflate, br',
        
        #'Content-type': 'application/json'}
        
        #urllib will override and send a close
        #'Connection': 'keep-alive'
        }

url1 = 'https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending'

req = request.Request(url1, data=None, headers=header)    
    
#5 second timeout for ncat, or any page that won't answer
try:
    resp = request.urlopen(req, timeout=5).read()
    with open('header_test.html', 'wb') as f:
        f.write(resp)

except http.client.HTTPException as e:
    print(e)
Open header_test.html in your web browser.
 
Old 03-17-2023, 09:35 PM   #176
jrosevear
LQ Newbie
 
Registered: Nov 2006
Distribution: Slackware
Posts: 29

Rep: Reputation: 14
I'd rather not advertise

Quote:
Originally Posted by vtel57 View Post
You'd rather not advertise what? Your operating system?
Right. By advertising I get to boast that I'm a Slackware user, but it also reveals sensitive information about my computer. I don't want to encourage anyone to mess with my computer.
 
1 members found this post helpful.
Old 03-18-2023, 04:39 AM   #177
vtel57
Senior Member
 
Registered: Jul 2006
Location: USA
Distribution: Slackware64 - 14.2 w/ Xfce
Posts: 1,631

Rep: Reputation: 489Reputation: 489Reputation: 489Reputation: 489Reputation: 489
Ah... OK.

Personally, I don't give a shit about that because my system is secure. The only worries I'd have with this system is if someone got physical access to it... and even then, it would take someone knowledgeable enough to get past my locks and passwords. That's not going to happen, though. Websites online knowing I'm running Slackware is no danger to me. When I'm not using this system, it's powered down completely.

But anyway, being wise about understanding your risks online is a good thing, so your thoughts on that with regards to your own system are smart.

Regards,

~E.
 
Old 03-18-2023, 08:07 AM   #178
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,152
Blog Entries: 6

Rep: Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835
You are not hiding anything by not reporting a particular user agent. Javascript is more of a threat to your privacy than using a slackware user agent. Loading images, the 1 pixel ones, tracks you more than a user agent does. Windows 11 doesn't even report that anymore. It reports as win10.

https://www.whatismybrowser.com/
https://www.whatsmybrowser.org/
https://smallseotools.com/what-is-my-browser/
https://browserleaks.com/

You can report a windows/mac user agent, you can still be fingerprinted to be a linux machine, and what your machine is capable of.

Misreporting a user agent in a web browser does not give you any added security. It'll get you a page source that you wish.
 
3 members found this post helpful.
Old 03-20-2023, 05:14 PM   #179
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth&Mars (I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that work on freest-HW; has been KDE, CLI, Novena-SBC but open.. http://goo.gl/NqgqJx &c ;-)
Posts: 4,888
Blog Entries: 2

Rep: Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567
Question

Quote:
Originally Posted by jrosevear View Post
Right. By advertising ...
what?
 
Old 03-20-2023, 05:16 PM   #180
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth&Mars (I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that work on freest-HW; has been KDE, CLI, Novena-SBC but open.. http://goo.gl/NqgqJx &c ;-)
Posts: 4,888
Blog Entries: 2

Rep: Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567
Quote:
Originally Posted by vtel57 View Post
Ah... OK.

Personally, I don't give a shit about that because my system is secure. The only worries I'd have with this system is if someone got physical access to it... and even then, it would take someone knowledgeable enough to get past my locks and passwords. That's not going to happen, though. Websites online knowing I'm running Slackware is no danger to me. When I'm not using this system, it's powered down completely.

But anyway, being wise about understanding your risks online is a good thing, so your thoughts on that with regards to your own system are smart.

Regards,

~E.
lol
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash: all --user-agent for "wget --user-agent " frenchn00b Programming 1 07-07-2009 05:25 AM
test26.s doesn't recognise DVD drive, other kernels won't recognise HDD v@ny@ Slackware - Installation 15 05-31-2007 06:03 AM
Error: Agent Configuration Agent (use Oracle with Linux) shipon_97 Linux - Enterprise 0 02-02-2007 12:11 AM
can't find ide.agent & block.agent for hotplug for 2.6 jg167 Linux - Newbie 1 06-23-2004 05:20 PM
Hotplug problems: RH 9, 2.6.6, PCMCIA-CS 3.2.7 (missing ide.agent & block.agent) jg167 Red Hat 1 06-23-2004 05:18 PM

LinuxQuestions.org > Forums > LinuxQuestions.org > LQ Suggestions & Feedback

All times are GMT -5. The time now is 07:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration