-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
35 lines (35 loc) · 7.6 KB
/
index.html
File metadata and controls
35 lines (35 loc) · 7.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE html>
<html lang="en"> <head><link rel="shortcut icon" href="/static/images/TechMonger%28CC%29.ico"><title>Executable But Not Readable Script - Linux - Tech Monger</title><meta charset="UTF-8"><meta http-equiv="x-ua-compatible" content="ie=edge"><meta name="description" content="Learn how to make your code executable but keeping it off from prying eyes by making it non readable."><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="canonical" href="/"><style>.lead{font-size:1.25rem;font-weight:300}</style></head> <body> <div class="container"> <header class="container"> <h1 class="row"><a href="/">Tech Monger</a></h1> <p class="lead row">Programming, Web Development and Computer Science.</p> </header> <span id="skiplinks" class="skip-link"> <a href="#main" title="Main Content on Page">Skip to main content</a>| <a href="#sidebar" title="Sidebar of Blog">Skip to information by topic</a> </span> <div class="row"> <main class="col-lg-9" id="main"> <article class="container" itemscope itemtype="https://schema.org/BlogPosting"> <h2><a href="/83/executable-but-not-readable/">How to Make Non Readable Linux File Executable</a></h2> <p itemprop="datePublished" title="21-04-30 17:20:15Z">Posted April 30, 2021</p> <div itemprop="articleBody"> <p class="lead">Many time you want to allow other Linux users to execute your code but restrict them from reading or writing it. Below we will show you unix trick where you can make binary file <em>non readable to users but allow execution</em> by adding <code>setuid</code> to your file.</p> <hr> <h4 id="prerequisite">Before we begin....</h4> <p> We need to note that this trick will only work with binary file and not the actual script which requires interpretation with interpreter. We have already explained how to convert <a href="/82/pyinstaller-script-to-binary/" title="Pyinstaller - Generate Binary from Python Script">python code to executable binary</a>. You can check the guide to covert your code to corresponding binary executable based on the programming language you are using. </p> <ul> <li> <p>Change Default Permission to Only Executable for all users except Owner. Here <code>hello</code> is the binary file</p> <pre class="bash top2"><code>$ cd /my/binaries/
$ chmod 711 hello
$ ls -la hello
-rwx--x--x 1 bob bob 5.5M Apr 30 22:12 hello</code></pre> </li> <li> <p>Switch to some other user and try executing file.... And user shall get error related to permission issues</p> <pre class="bash top2"><code>$ sudo su - alice
$ cd /my/binaries/
$ ./hello
[31868] Cannot open self /my/binaries/hello or archive </code></pre> </li> <li> <p>Make <code>hello</code> executable by adding setuid flag with <strong>4</strong>711</p> <pre class="bash top2"><code>$ chmod 4711 hello
$ ls -la hello
<b>-rws--x--x</b> 1 bob bob 5.5M Apr 30 22:12 hello</code></pre> </li> <li> <p>Now ask alice to try again</p> <pre class="bash top2"><code>$ sudo su - alice
$ cd /my/binaries/
$ ./hello
Hello World</code></pre> </li> </ul> <h3>Conclusion</h3> <div class="card"> <p class="card-body"> Here we learned how to make use of <code>setuid</code> flag to allow Alice to execute non readable binary file which is owned by the Bob.</p> </div> </div> <p class="top3">Tagged Under :<span itemprop="keywords"> <a href="/tag/linux/">Linux</a> <a href="/tag/open-source/">Open Source</a> </span> </p> </article> <div class="top3"> <div class="col-sm-9"> <span class="float-left"> <a class="btn btn-secondary btn-md" role="button" aria-disabled="false" href="/82/pyinstaller-script-to-binary/" title="Python Script to Cross Platform Binary - PyInstaller">Previous</a> </span> <span class="float-right"> <a class="btn btn-secondary btn-md disabled" role="button" aria-disabled="true" href="#">Next</a> </span> </div> </div> </main> <aside class="col-lg-3 top5" id="sidebar"> <div class="text-right"> <h3>Tags</h3> <nav> <ul> <li class="list-unstyled"><a href="/tag/davmail/" title="Davmail Setup and Configuration">Davmail</a></li> <li class="list-unstyled"><a href="/tag/flask/" title="Flask Web Development">Flask</a></li> <li class="list-unstyled"><a href="/tag/google-cloud/" title="Google Cloud Tutorials and Examples">Google Cloud</a></li> <li class="list-unstyled"><a href="/tag/informatica/" title="Informatica Administration Tutorials">Informatica</a></li> <li class="list-unstyled"><a href="/tag/linux/" title="Linux Desktop and Server - Tutorials">Linux</a></li> <li class="list-unstyled"><a href="/tag/localtunnel/" title="Localtunnel Tutorials - HTTP Tunnel in Action">Localtunnel</a></li> <li class="list-unstyled"><a href="/tag/open-source/" title="Tutorials about open source software ">Open Source</a></li> <li class="list-unstyled"><a href="/tag/python/" title="Python Programming">Python</a></li> <li class="list-unstyled"><a href="/tag/raspberry-pi/" title="Raspberry Pi Tutorials and Hacks">Raspberry Pi</a></li> <li class="list-unstyled"><a href="/tag/thunderbird/" title="Thunderbird Tutorials">Thunderbird</a></li> <li class="list-unstyled"><a href="/tag/ubuntu/" title="Ubuntu Tutorials">Ubuntu</a></li> <li class="list-unstyled"><a href="/tag/web/" title="Tutorials for Full Stack Web Developers">Web</a></li> <li class="list-unstyled"><a href="/tag/windows/" title="Windows Software and Tutorials">Windows</a></li> <li class="list-unstyled"><a href="/tag/wordpress/" title="Wordpress Tutorials and Guides">Wordpress</a></li> </ul> </nav> </div> <div class="top4 bottom4 float-left"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:inline-block;width:336px;height:280px" data-ad-client="ca-pub-1476292113673713" data-ad-slot="8720400182"></ins> <script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script> <div> <div class="text-center"> <a class="top5" href="/feeds/" title="Atom Feed - Tech Monger"><i class="fa fa-rss" aria-hidden="true"></i> Feeds</a> </div> </aside> </div> <hr class="top3"> <footer class="top5 text-secondary"> <div class="container-fluid text-center text-md-left"> <div class="row"> <div class="col-md-4 mt-md-0 mt-3"> <h5 class="text-uppercase">About</h5> <p>Techmonger is a web log which shares interesting articles about computer science, programming and web development.</p> </div> <hr class="clearfix w-100 d-md-none pb-3"> <div class="col-md-3 mb-md-0 mb-3"> <h5 class="text-uppercase">Pages</h5> <ul class="list-unstyled"> <li> <a href="/privacy.html">Privacy Policy</a> </li> <li> <a href="/contact.html">Contact</a> </li> </ul> </div> <div class="col-md-5 mb-md-0 mb-3"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:inline-block;width:468px;height:60px" data-ad-client="ca-pub-1476292113673713" data-ad-slot="1929762560"></ins> <script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script> </div> </div> </div> </footer> <div class="top3"></div> <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.css"> <script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.js"></script> <script>
window.addEventListener("load", function(){
window.cookieconsent.initialise({
"palette": {
"popup": {
"background": "#ffffff"
},
"button": {
"background": "#e0e0e0",
"text": "#0a0202"
}
},
"theme": "edgeless",
"content": {
"dismiss": "Accept",
"href": "/privacy.html"
}
})});
</script> </div> <link rel="stylesheet" type="text/css" href="/static/css/style.css"> <script src="/static/js/scripts.js"></script> <script>hljs.initHighlightingOnLoad();</script> </body> </html>