Is it possible to disable reading hosts file by libCurl - c++

There is a detection in VirusTotal: remote System Discovery T1018: Reads the hosts file. For testing I want to get rid of this detection. I suppose that it is libCurl, who reading this file.
Is it possible to disable libCurl from reading hosts and what are consequenses of that?

You can set the CURLOPT_RESOLVE option to explicitly specify the IP address of the remote host in the request. This will bypass the need for libCurl to resolve the hostname using the hosts file.

Related

How to get the TFTP server address from the DHCP configuration

I need to find out the address of the TFTP server that is specified in the DHCP configuration.
When the PC is started on, the computer receives the IP address via DHCP, then downloads the image from the PXE server. During the download of the distribution, I need to run a utility that accesses the Database to the server from which this image was downloaded (where the TFTP server is running).
In theory, it would be possible to register the necessary address of the TFTP server in the downloadable image of the distribution. But the bottom line is that such a scheme exists in various subnets. And specifying its TFTP server for each subnet is an irrational approach. It would be more convenient to get the address of the TFTP server from the DHCP server, which is listed there as next-server
I found something similar at Busybox.
Is it possible to implement something like this in C/C++ and how can it be done? I don't have any ideas.
Some example of the code of contacting the DHCP server to get an address or parameter. Open a socket and make a request or something like that... At least I haven't found any similar examples on the Internet.
P.S. I will put a dislike and send it to read man, than I will answer the question constructively. Nice!
If you are using the ISC dhcp-client then
man dhclient-script
If you are using some other dhcp client then it might have support for calling scripts too. Or it might store the dhcp lease somewhere in a parseable format, like /var/lib/dhcp/dhclient.leases. You can extract the dhcp options from that.

Packer with vsphere waiting for IP timeout

I am attempting to create VMWare templates using Packer. I have a simple file that is essentially a copy of https://github.com/guillermo-musumeci/packer-vsphere-iso-windows/tree/master/win2019.base.
When I build this it times out at "Waiting for IP".
The network it is using is set for static IP, so I suspect it is that, but how do I define a static IP for this? and does it really need this for template creation?
Thanks
I’ve had similar issues with vsphere-iso packer build. It was caused by using the wrong IP for the HTTP directory especially when I was on my company’s VPN vs being hardwired. Thus, it was continually stuck at 'Waiting for IP'. The issue was the order of priority that packer uses to determine what interface to use for the HTTP directory which contains my kickstarter file. The interface that it was choosing was not accessible from the vsphere instance. Could this be the issue?
How we solved this, is that we actually have a shell wrapper that calls packer. Within that script, we ask the user for an IP that the HTTP directory should be accessed at. I use ifconfig and look at the 10. IP in the list. The shell script passes on that environmental variable to my packer's build.json. Its not the cleanest solution, but Ive been using this fix for months.

send logs to syslog server using cpp

I need to send logs to syslog server using cpp. Syslog server maybe configured on same machine or different machine in the network. Syslog server maybe present on windows or linux machine. Is there any third party library which I can use to forward logs to the syslog server ? Cpp will be preferred option for me to code. If third party library is not present what will be better option ?
you can use the syslog.conf file, instead of the sy

how to Configure DHCP time out via program?

On Linux machine i would like to write a program to change the timeout value of DHCP connection (How long the DHCP client can wait before giving up).
i went through the https://askubuntu.com/questions/203157/timeout-in-a-connection-to-a-dhcp-server but this provides the change of configuration file manually.
Please provide some help
The DHCP client settings are stored in an ordinary text file, dhclient.conf. There's a timeout <time>; option that you want to add or change.

C++, Ifstream opens local file but not file on HTTP Server

I am using ifstream to open a file and then read from it.
My program works fine when i give location of the local file
on my system.
for eg
/root/Desktop/abc.xxx works fine
But once the location is on the http server the file fails to
open.
for eg
http://192.168.0.10/abc.xxx fails to open.
Is there any alternate for ifstream when using a URL address?
thanks.
There are no utilities in the standard C++ library for accessing data via http protocol.
There are 3rd-party libraries though:
Libwww
libcurl
Another option is to have a virtual filesystem that maps remote http files as local files. This way you don't have to modify your application to access http. Something like http://okmij.org/ftp/HTTP-VFS.html
ifstream will not read files off of an HTTP Server. It will only read local files.
The f in ifstream is for file, not socket.
You need to make an HTTP GET Request and then stream the response, this is a totally different operation.
Consider using boost::asio, or similar. [Examples]
Update
Since the web server is on your local area network (judging by the IP address - not sure why people still insist in using those in these heady days of DNS, but that's by the by), you could probably mount the filesystem containing the desired file on your local machine, using NFS or similar. Then you'd be able to perform file operations, such a reading with ifstream.
ifstream only works with files accessible on the filesystem, not on web servers.